import into global namespace
Chris Withers
chrisw at nipltd.com
Thu Jul 20 08:15:20 EDT 2000
Hi again :-)
Okay, after all the fun of loading modules from strings this one should
be a little simpler :-)
Right, I have the following code getting called in a function:
exec "from %s import *" % moduleName
...which works great, but I'm guessing only imports stuff into the
function's namespace, so other functions can't use the imported modules
:(
I know I can do exec "from %s import *" % moduleName in globals,locals
What would I set globals and locals to so that the import happens
globally and all functions will have access to the imported names from
the module?
cheers,
Chris
More information about the Python-list
mailing list