[Andrew Koenig]
> ...
> Incidentally, I think that lexical scoping would also deal with the problem
> that people often encounter in which they have to write things like "lambda
> x=x:" where one would think "lambda x:" would suffice.

They _shouldn't_ encounter that at all anymore.  For example,

>>> def f(x):
...     return lambda: x+1
>>> f(3)()
4

works fine in modern Pythons.  Earlier Python's had a no-exceptions
3-scope implementation (local, global, builtin), and in those the "x"
in the lambda body was "not local" (was either global or builtin,
although the compiler couldn't tell which of those two it was).  In
_those_ Pythons people had to write "lambda x=x: x+1" instead, to suck
the binding of the outer x into the lambda body, but if people are
still doing that they're confused.  Modern Pythons do have lexical
scoping + global + builtin, although there's no way to spell "rebind a
name local to an outer scope from within an inner scope".
_______________________________________________
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