passing options to __import__

Alex Martelli aleax at
Wed Apr 4 06:39:01 CEST 2007

Harold Fellermann <dadapapa at> 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).


More information about the Python-list mailing list