passing options to __import__

Alex Martelli aleax at mac.com
Wed Apr 4 00:39:01 EDT 2007


Harold Fellermann <dadapapa at googlemail.com> wrote:
   ...
> Within my program, I am importing a module via
> __import__(module_name,globals(),locals())

The globals() you're passing are those of the *importing* module, and
have no effect on those of the *imported* module.

> and I want to pass comand line options to this module. I would prefer

command-line options are sys.argv -- a list you can set in any way you
want before you __import__.  Generally unwise to "fake" it, but it may
sometimes come in handy for purposes of testing (and no others).


Alex



More information about the Python-list mailing list