Joshua Ginsberg wrote:
> Try this one:
>
>>>> d = {}
>>>> for x in [1,2,3]:
> ... d[x] = lambda *args: args[0]*x
> ...
>>>> d[1](3)
try it with:
d[x] = (lambda x=x: (lambda *args: args[0]*x))()
the outer lambda fixes the value of x and produces the inner lambda
with the fixed x value
--eric
--
http://mail.python.org/mailman/listinfo/python-list
