How do I do this? (eval() on the left hand side)
Nick Coghlan
ncoghlan at iinet.net.au
Fri Dec 10 06:59:53 EST 2004
Carl Banks wrote:
> Modifying globals() not even necessary for this. When I want to
> dynamically update the global namespace, I do it this way:
>
> mod = __import__(__name__)
> setattr(mod,symbol,value)
>
> Works perfectly unless you're worried about someone modifying the built
> in __import__.
Well, aside from the detail that modifying a module's contents via a reference
to that module is far more evil than playing with globals() ;)
Even if that module is the one you're running in. . .
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
More information about the Python-list
mailing list