How do I do this? (eval() on the left hand side)
Carl Banks
imbosol at aerojockey.com
Thu Dec 9 23:00:25 CET 2004
Peter Hansen wrote:
> In general I would say that mucking with globals() like this is
> probably best restricted to constants like in this case, if at all.
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__.
--
CARL BANKS
More information about the Python-list
mailing list