A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-July/066874.html below:

[Python-Dev] 2.5 and beyond

[Python-Dev] 2.5 and beyondGiovanni Bajo rasky at develer.com
Sat Jul 1 02:01:00 CEST 2006
Tim Peters <tim.peters at gmail.com> wrote:

>> ...
>> 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.

Yes but:

>>> a = []
>>> for i in range(10):
...     a.append(lambda: i)
...
>>> print [x() for x in a]
[9, 9, 9, 9, 9, 9, 9, 9, 9, 9]

This subtle semantic of lambda is quite confusing, and still forces people to
use the "i=i" trick.

Giovanni Bajo

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4