Update locals()

Donn Cave donn at drizzle.com
Tue Apr 30 02:35:12 EDT 2002


Quoth Alex Martelli <aleax at aleax.it>:
...
| Right, and THAT is the issue: exec-without-explicit-dicts DOES muck
| with the local namespace in ways that cannot be controlled and thus
| lead to unmaintainable code, hard-to-find bugs, and so on.

I have to say, I don't think I've seen this much horror expressed
about "exec" before today.  I certainly don't reach for exec as the
tool for every problem, but I do use it in one application in
class statements where its intent is precisely to muck with the
local namespace.  It works fine, isn't hurting anything and isn't
going to randomly write zeros across my namespace.  I'm not saying
its uses are many, but ideas like "abomination" are for the religious.

I haven't read every word of this exchange, but I did take a look
at compile() and new, and if this is the approved way to do things
we need a little more documentation ("You need to know a great deal
about the interpreter to use this!", as new.__doc__ says, is a
starter, but perhaps could be more specific.  I was stumped, anyway.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list