Anonymous user
Closures/Value capture: Difference between revisions
→{{header|Python}}
Line 624:
print funcs[3]() # prints 9</lang>
It is also possible to use <code>eval</code>
<lang python>funcs=[eval("lambda:%s"%i**2)for i in range(10)]
print funcs[3]() # prints 9</lang>
|