How to pass parameter to a module?

M-a-S NO-MAIL at hotmail.com
Thu Sep 18 06:11:01 EDT 2003


I'd like to parametrize a module. That is, to set and pass
some values into the module, while it is being imported.
I tried this:

  # sub_1.py -- main program
  extern = "OK"
  import sub_2
  print sub_2.noway # prints 'no extern' :-(
  # EOF

  # sub_2.py -- parametrized module, parameter is the 'extern' var
  try:
     noway = extern
  except:
     noway = 'no extern'
  # EOF

You can guess, it doesn't work.
How can I pass the parameter? Can I?
M-a-S






More information about the Python-list mailing list