Hi,

>From previous post, I get many helpful replies. Now I have a new question
when I run this example code:


---------
sq=[]
for xx in range(5):
    print 'here'
    sq.append(lambda:xx**2)
    
here
here
here
here
here

xx
Out[150]: 4

sq[2]()
Out[151]: 16

sq[3]()
Out[152]: 16
/////

There are only one time 5 'here' printed out, but there is no 'here' print
out in thereafter call sq[2]() etc. How to understand this phenomenon?

Thanks,

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to