Guido van Rossum wrote:

> Another idea might be to change the exec() spec so that you are
> required to pass in a namespace (and you can't use locals() either!).
> Then the whole point becomes moot.

I think of exec as having two major uses:

(1)  A run-time compiler
(2)  A way to change the local namespace, based on run-time
information (such as a config file).

By turning exec into a function with its own namespace (and
enforcing a readonly locals()), the second use is eliminated.

Is this intentional for security/style/efficiency/predictability?

If so, could exec/eval at least

(1)  Be treatable as nested functions, so that they can *read* the
current namespace.
(2)  Grow a return value, so that they can more easily pass
information back to at least a (tuple of) known variable name(s).

-jJ
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to