[Python-ideas] nonlocal functions

Mike Meyer mwm-keyword-python.b4bdba at mired.org
Fri Oct 23 00:56:28 CEST 2009

On Thu, 22 Oct 2009 08:57:15 -0700
Bruce Leban <bruce at leapyear.org> wrote:
> taking out the global/nonlocal statements would break too much code. And :-)
> we'd have to figure out what this statement means:
>     foo = bar + global.bar + nonlocal.bar

I know there's a smiley, but it seems obvious. Further, it seems
*useful*. If I have a local bar, a nonlocal bar and a global bar right
now, I'm pretty much SOL for getting the global and local bars values
(ok, I can get the global bar with some chicanery, but I can't see how
to get the nonlocal bar). Making those namespaces explicit would seem
to be as much of a win as making "self" explicit.

Of course, you might argue that anyone who created three such
variables named bar deserves to be barred, but...

Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

More information about the Python-ideas mailing list