Safe to modify globals(), or not?

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

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

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