lambda-funcs problem

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Sep 19 15:54:48 EDT 2007


Stéphane Larouche a écrit :
(snip)
> 
> funcs = [(lambda i: lambda x: x+i)(i) for i in xrange(10)]

A bit more complex than necessary... The canonical solution is
funcs = [lambda x, i=i: x+i for i in xrange(10)]





More information about the Python-list mailing list