[issue47028] Incorrect behaviour when zipping a bunch of maps
Dennis Sweeney
report at bugs.python.org
Tue Mar 15 12:16:17 EDT 2022
Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:
This is because i is not captured by the function definition. `lambda x: x**i` always makes the "input to the ith power" function, never the "input to the 3rd power" function, even if i happens to be 3 right now.
Consider replacing `lambda x: x**i` with `lambda x, i=i: x**i` to explicitly capture the current value of i as a default.
Changing the scoping rules now would be a big backwards-incompatible change.
----------
nosy: +Dennis Sweeney
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47028>
_______________________________________
More information about the Python-bugs-list
mailing list