title: Bug import main with arguments in Python
body: <p>In a script I'm trying to import the main module from another script with an argument.</p>
  
  <p>I get the error message "NameError: global name 'model' is not defined". </p>
  
  <p>If someone sees the mistake, I'd be grateful !</p>
  
  <p>My code :</p>
  
  <p>script1</p>
  
  <pre><code>#!/usr/bin/python
  
  import sys
  import getopt
  import pdb
  import shelve
  
  class Car:
      """ class representing a car object """
      def __init__(self, model):
          self.model = model
  
  class Porsche(Car):
      """ class representing a Porsche """
      def __init__(self, model):       
          Car.__init__(self, model)
          print "I have a Porsche but no driving licence : too bad !"
  
  # Main
  def main(argv):
  
      settings = shelve.open('mySettings')
      global model
      try:
          opts, args = getopt.getopt(argv, "m:", ["model="])
      except getopt.GetoptError, err:
             print " wrong argument, exiting "
             sys.exit()
      for opt, arg in opts:
          if opt in ("-m", "--model"):
              model = arg
  
      def choose_car(model):
          """ Creates the car"""
          my_Porsche = Porsche(model)     
  
      choose_car(model)
  
  if __name__ == "__main__":
     main(sys.argv[1:]) 
  </code></pre>
  
  <p>script2</p>
  
  <pre><code>#!/usr/bin/python
  
  import os
  import sample
  import sys
  
  def main(argv):
          script1.main("-m Carrera")
  
  # Main program
  if __name__ == '__main__':
      main(sys.argv[1:])
  </code></pre>
  
  <p>rgds, </p>