Closures/Value capture: Difference between revisions

Line 624:
print funcs[3]() # prints 9</lang>
 
It is also possible to use <code>eval</code> and eliminate the double function.
<lang python>funcs=[eval("lambda:%s"%i**2)for i in range(10)]
print funcs[3]() # prints 9</lang>
Anonymous user