On Fri, 12 Oct 2007 01:00:47 -0400, Zhu Wayne wrote
> Hi,
> I have a short code which gives me strange results, the code is as follows:
>
> f = [lambda x: None]*5
> for j in range(0, 5):
> f[j] = lambda x: float(j)*x
> [...]
> It seems only when I use the index j (which is declear with
Hi,
I have a short code which gives me strange results, the code is as follows:
f = [lambda x: None]*5
for j in range(0, 5):
f[j] = lambda x: float(j)*x
print "print f[k](1.),"
for k in range(5):
print f[k](1.),
print "expect 0. 1. 2. 3. 4."
print
print "print f[j](1.),"
for j in range(5