|
|
|
|
|
by glomek
6278 days ago
|
|
Seems fine to me. If you want the captured variable to be different each time, you need to create a new environment each time. How about this? >>> fs = [(lambda x: (lambda n: x + n))(i) for i in range(10)]
>>> [f(4) for f in fs]
[4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
>>>
|
|