Message22930
I know that this has been broken for a long time, but I
thought that it would be addressed by 2.4. I couldn't
find it in the bug database. Here's the problem:
$ python2.4
Python 2.4b1 (#1, Oct 25 2004, 01:44:03)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> x = [lambda:a for a in range(5)]
>>> x[0]()
4
>>> x[1]()
4
The workaround is the old bind-the-arg trick:
>>> x = [lambda a=a:a for a in range(5)]
>>> x[0]()
0
>>> x[1]()
1
|
|
Date |
User |
Action |
Args |
2007-08-23 14:27:09 | admin | link | issue1056483 messages |
2007-08-23 14:27:09 | admin | create | |
|