nested scopes

Tim Peters tim.one at home.com
Sun Feb 4 05:53:47 CET 2001


[/F]
> I'm beginning to suspect that a new "sorry, you can no longer
> nest def statements" might have been an easier sell...

Not a chance.  You can't stop people from complaining, you can only
influence *what* they complain about.  If Python never ever changed anything
again, there would be howls of protest against that too.  It's much easier
to bear complaints about enforcing something the Reference Manual always
said you shouldn't do (while it's far from certain things will stay this way
for the beta release, if they do then "sorry, but tough luck" is a
defensible response).

[Aahz, Copyright 2001 by aahz at pobox.com, reproduced without permission]
> Taking that seriously, that would cause problems for classes.

/F meant "a def block can no longer contain a def block".  It's curious how
few have ever complained that a def inside a class doesn't have automagic
access to the class locals.  But do the same thing wrt a def in a def, and
it's like Guido is trying to use the time machine to go back and kill John
McCarthy's mother before he was born <wink>.

> Not to mention the lambda issue, which I personally would be just
> as happy to see go bye-bye.

Well, it *has*, but in the way people expect:

>>> def f(n):
...     return lambda i: i + n
...
>>> f(3)(4)
7
>>>

No more "n=n" abuse needed.  Politically impossible to remove lambda at this
stage anyway.  lambda is the print>> of Pytnon functions <wink>.





More information about the Python-list mailing list