3 ms·
"Just fine" is papering over the fact that people get tripped up by this in Python all the time – sometimes you need to use the `global` or `nonlocal` statement
by exogen 12y ago
"Just fine" is papering over the fact that people get tripped up by this in Python all the time – sometimes you need to use the `global` or `nonlocal` statements to resolve the ambiguity.
https://docs.python.org/3/reference/simple_stmts.html#global https://docs.python.org/3/reference/simple_stmts.html#global
https://docs.python.org/3/reference/simple_stmts.html#nonlocal https://docs.python.org/3/reference/simple_stmts.html#nonloc...
Classic example: http://stackoverflow.com/questions/9264763/unboundlocalerror-in-python http://stackoverflow.com/questions/9264763/unboundlocalerror...
If you search for UnboundLocalError on StackOverflow, there are 918 results. Not all of them are due to this particular scoping ambiguity, but many of them are.