funcs vs vars in global namespace

David Rysdam drysdam at
Tue Sep 14 19:40:55 CEST 2004

Alex Martelli wrote:
> David Rysdam <drysdam at> wrote:
>    ...
>>>sub_module = __import__(which_one_this_time)
>>>print sub_module.the_function(23)
>    ...
>>Oh wow, of course!  I can set properties on the modules themselves.  I'm
>>going to have to rethink what I'm doing and mess with that a bit, I'm
>>sure I'll have questions and problems later.  Thanks!
> You're welcome!  Yes, since your modules are not being used for other
> purposes except running the scriptlets you're controlling, changing
> those modules' global variables should be safe enough in your case.
> Alex

OK, dumb question #1:

Why do this:

sub_module = __import__(which_module_this_time)

When I could just do this:

__import__(which_module_this_time, which_dict_this_time)


More information about the Python-list mailing list