Safe to modify globals(), or not?

Robert Dodier robert_dodier at yahoo.com
Sat Jan 31 16:46:00 CET 2004


Peter Otten <__peter__ at web.de> wrote:
[...]
> <interp.py>
> import sys
> import __main__
> setattr(sys.modules["__main__"], "name", "value")
> __main__.anotherName = "another value"
> </interp.py>

Thanks a lot, Peter, this is just the right thing. 
I guess modifying globals() is a non-issue, as it turns out.
I appreciate your help.

Robert Dodier



More information about the Python-list mailing list