Namespace Mystery (HELP!)

Moshe Zadka moshez at math.huji.ac.il
Fri Jul 7 13:55:28 EDT 2000


On Fri, 7 Jul 2000, Paul Prescod wrote:

> Dunno. :( I'm surprised that raw "exec" can modify local variables but
> then I never use it. I'm one of those anti-exec purists.

Me too. However, I've used "exec", so I want to talk in a few words about
the two situations in which "exec" is useful.

A. A Plug-in architecture. In writing an IDE (which is not yet in a
releasable condition) I wanted to have an EMACS-like extensions and hooks.
"exec <user code> in {}" proved very efficient for that. In a sense, this
is a form of exec which any language has: even C, via dlopen() and
dlsym().

B. In this same IDE, I wanted a user to be able to run the Python program
she wrote. Here too, "exec <user code> in {}" proved simple and to the
point.

Conclusion:
Never ever "exec" without using the "in" form. I have yet to see a reason
to break this rule.

almost-as-bad-as-an-unqualified-execpt-ly y'rs, Z.
--
Moshe Zadka <moshez at math.huji.ac.il>
There is no GOD but Python, and HTTP is its prophet.





More information about the Python-list mailing list