Hello snakes :) In [38]: f = [lambda:i for i in range(10)] In [39]: ff = map(lambda i: lambda : i, range(10)) In [40]: f[0]() Out[40]: 9 In [41]: f[1]() Out[41]: 9 In [42]: ff[0]() Out[42]: 0 In [43]: ff[1]() Out[43]: 1
I don't understand why in the first case f[for all i in 0..9]==9 what is different from (more usefull) In [44]: f = ["%i" % i for i in range(10)] In [45]: f Out[45]: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] doing it like this works again In [54]: def d(x): ....: return lambda:x ....: In [55]: f = [d(i) for i in range(10)] In [56]: f[0]() Out[56]: 0 In [57]: f[1]() Out[57]: 1 in a C programmer sence I would say there seems to be no "sequence point" which would separate "now" from "next" Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list