Avoiding `exec', how to?
François Pinard
pinard at iro.umontreal.ca
Thu May 30 16:48:28 EDT 2002
[Steven Majewski]
> If you have to get a handle to a module while it's being executed
> on it's initial import, you can use:
> import sys
> module = sys.modules[__name__]
It works very nicely, thanks for the idea. I now happily have:
# Fabriquer une variable globale pour chaque élément de DEFS.
module = sys.modules[__name__]
for name, value in defs.__dict__.items():
if name[0] != '_':
setattr(module, name, value)
del module, defs, name, value
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list