[wingide-users] global imports
Paul Du Bois
dubois at doublefine.com
Wed Jun 8 13:25:14 MDT 2011
> >> def init(a, b, c):
> >> for module in a,b,c:
> >> globals().update(module.__dict__)
> Hmmm.... so a, b & c are the names of modules that I want to "import",
> If so, this just might work. I'll have to check the docs on this one.
No they are NOT the names. They are the modules themselves. Re-read
the original code snippet:
import parameter1, parameter2, parameter3
subroutines.init(parameter1, parameter2, parameter3)
I believe you may already have a list of names you want to steal from
the modules; I presume your current import statement in subroutines.py
from <something> import w,x,y,z, ...
If you have that list, you can do something like this instead of
stealing the entire contents of the module:
for name in ('w', 'x', 'y', 'z'):
globals()[name] = getattr(param_module, name)
modules are just like any other object in this respect.
More information about the wingide-users