3 ms·
You are wrong about Python. It absolutely does the wrong thing: >>> funcs = [] >>> for i in range(10): ... def f(): ... print(i) ...
by earthboundkid 5y ago
You are wrong about Python. It absolutely does the wrong thing:
>>> funcs = []
>>> for i in range(10):
... def f():
... print(i)
... funcs.append(f)
...
>>> [f() for f in funcs]
9
9
9
9
9
9
9
9
9
9
[None, None, None, None, None, None, None, None, None, None]