Created on 2004-10-29 00:59 by dsblank, last changed 2004-10-29 01:50 by rhettinger. This issue is now closed.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2004-10-29 00:59:42 | dsblank | create | |
Created on 2004-10-29 00:59 by dsblank, last changed 2004-10-29 01:50 by rhettinger. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg22930 - (view) | Author: Doug Blank (dsblank) | Date: 2004-10-29 00:59 | |
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 |
|||
| msg22931 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2004-10-29 01:50 | |
Logged In: YES user_id=80475 Sorry, this is not a bug. Someone on comp.lang.python or python-tutor would be happy to explain it. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2004-10-29 00:59:42 | dsblank | create | |