How do I do this? (eval() on the left hand side)

Carl Banks imbosol at aerojockey.com
Fri Dec 10 16:10:54 EST 2004


Nick Coghlan wrote:
> 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. . .

It seems to me that that which makes modifying a module's contents via
a reference evil makes modifying them via globals() equally evil.  The
only thing is, modifying them through a module reference is explicit
and straightforward, whereas modifying the contents via globals() is an
implicit, backhanded trick that relies on certain behind-the-scenes
behavior.

I'd say using globals() is far eviler.  So I must disagree with your
good-natured objection.  Unless there's some practical weakness of
using references that I am unaware of.
-- 
CARL BANKS
(Yes, I know eviler is not a word.)




More information about the Python-list mailing list