10 ms·
Whoops, actually the python version only works if you move total AND add a nonlocal keyword. https://docs.python.org/3/reference/simple_stmts.html?highlight=no
by intrepidhero 4y ago
Whoops, actually the python version only works if you move total AND add a nonlocal keyword.
https://docs.python.org/3/reference/simple_stmts.html?highlight=nonlocal#nonlocal https://docs.python.org/3/reference/simple_stmts.html?highli...
- bhk 4y agoThe existence of `nonlocal` is an indictment of the local-by-default design. (Parenthetically, for completeness, I should note that this is a problem only when the language supports mutable variables or, more precisely, mutable captures or "upvalues", which I think are also a bad idea, but that's another bag of worms for another day.)