function object and copies of variables

stan at saticed.me.uk stan at saticed.me.uk
Tue Nov 2 18:40:25 CET 2004


can a function object store values so this 3 liner can print 0 1 instead
of 1 1?

f = []
for i in [0, 1]: f.append(lambda: i)
for j in f: print j()


TIA



More information about the Python-list mailing list