Update locals()

Alex Martelli aleax at aleax.it
Mon Apr 29 08:36:38 EDT 2002


<posted & mailed>

holger krekel wrote:
        ...
> OF COURSE i didn't mean that re.compile mucks with the local namespace.

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.


> re.compile compiles a pattern into a pattern object which
> can be used for searches. In the above case the helper
> uses exec to dynamically construct a function object from
> a pattern. That's why i said 'similar' technique. Why are
> you often assuming the worst of all interpretations?

Because the ONLY important issue here is whether having your local
namespace uncontrollably altered depending on a string's contents
can ever be *preferable* to keeping your namespace under control.

The ONLY specific functionality that exec-without-explicit-dicts
(EWOED for short) "gives" you is exactly the ability to enable such
uncontrolled namespace alteration.  And that is exactly what makes
it an abomination.

You can "dynamically construct a function object from a pattern"
in many OTHER ways than with EWOED.  These are "designed", or maybe
better, "architected" ways, controlled and controllable, while
EWOED is a "doomsday device" able to wipe out anything in its path.


> If you are coming to EuroPython maybe we find half an hour where we
> can discuss it on the screen? Doing this in mail makes it hard to not
> misunderstand each other.

I think I'll be at EuroPython, yes, although I don't understand what
you can possibly mean by "on the screen" in this context (it seems to
me that the inability to understand what you can possibly mean is
turning out to be frequent on my part -- just to double check, is
everybody else perfectly clear about what this "on the screen" is
meant to convey, or is it just as murky to everyone?).  Let's see if
that can help.  But the specific issue is "what are the alleged
advantages of losing control of my local namespace" -- dynamic
generation of code through the many OTHER, CONTROLLED means that
Python offers has its (SMALL) place, it's the uncontrolled 'power'
of namespace-destruction that (like the uncontrolled 'power' of
GOTO, vs the controlled means of architected control-structures)
I believe should be 'considered harmful' and to have NO place in
production code.


Alex




More information about the Python-list mailing list