[Python-Dev] anonymous blocks
jcarlson at uci.edu
Wed Apr 20 00:21:27 CEST 2005
[Guido van Rossum]
> would become something like
> def __block():
> I'm not yet sure whether to love or hate it. :-)
Is it preferable for CODE to execute in its own namespace (the above
being a literal translation of the given code), or for it to execute in
the originally defined namespace?
Deferring to Greg Ewing for a moment :
They should be lexically scoped, not dynamically scoped.
Wrapped blocks in an old namespace, I believe, is the way to go,
especially for things like...
a = foo.method()
I cannot come up with any code for which CODE executing in its own
namespace makes sense. Can anyone else?
<discussion on the overlap with PEP 310 removed for brevity>
More information about the Python-Dev