Twisted (or for loops ?) madness
Michele Simionato
michele.simionato at gmail.com
Mon Oct 15 06:33:17 EDT 2007
More information about the Python-list mailing list
Mon Oct 15 06:33:17 EDT 2007
- Previous message (by thread): Twisted (or for loops ?) madness
- Next message (by thread): Twisted (or for loops ?) madness
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Oct 15, 12:10 pm, looping <kad... at gmail.com> wrote: > > Why lambda doesn't work ? (variable scope problem ?) This is a well known issue of for loops. Some believe it to be a bug but Guido says it is a design decision, in the sense that Python always do late binding. If you browse this list you will find many discussions. Basically if you do funclist = [] for i in 1,2,3: def f(): print i funclist.append(f) you will get funclist[0]() == funclist[1]() == funclist[2]() == 3 (you get the latest binding of "i"). As you see, it has nothing to do with lambdas. Michele Simionato
- Previous message (by thread): Twisted (or for loops ?) madness
- Next message (by thread): Twisted (or for loops ?) madness
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list