problem with tk and pass by refference (I think :)
Diez B. Roggisch
deetsNOSPAM at web.de
Fri Feb 11 15:20:15 EST 2005
> I tried it but I got a syntax error. The interpreter didn't like the
> equals sign in the lambda. I am using python 2.3.4. Is there another way
> of writing that?
Strange. This script works and shows the desired behaviour - python is also
2.3.4:
def foo(x):
print x
fs = [lambda: foo(i) for i in xrange(5)]
for f in fs:
f()
fs = [lambda x=i: foo(x) for i in xrange(5)]
for f in fs:
f()
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list