lambda semantics in for loop

Tomek Meka tmeka at gmx.net
Sun Jan 5 08:56:28 EST 2003


Hi!
You could also write:
def f(i):
    def g(x):
        return i + x
    return g

and then:

l = []
for i in range(10):
     l.append(f(i))

Regards,
Tomek





More information about the Python-list mailing list