funcs vs vars in global namespace

Alex Martelli aleaxit at yahoo.com
Tue Sep 14 19:07:04 CEST 2004


David Rysdam <drysdam at ll.mit.edu> wrote:
   ...
> > sub_module = __import__(which_one_this_time)
> > vars(sub_module).update(which_dict_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



More information about the Python-list mailing list