the following code:
tab = [lambda: elt for elt in [1,2,3,4,5]]
for elt in tab:
print(elt())
gives the following output:
➜ ~ python code.py
5
5
5
5
5
Is there any way to switch off (or weaken) this optimisation?
the following code:
tab = [lambda: elt for elt in [1,2,3,4,5]]
for elt in tab:
print(elt())
gives the following output:
➜ ~ python code.py
5
5
5
5
5
Is there any way to switch off (or weaken) this optimisation?