[issue46612] Unclear behavior of += operator

Eric V. Smith report at bugs.python.org
Wed Feb 2 11:38:45 EST 2022


Eric V. Smith <eric at trueblade.com> added the comment:

The "evaluate the target" part causes the UnboundLocalError, just as in:

>>> x=1
>>> def f():
...   x
...   x = x + 1
... 
>>> f()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in f
UnboundLocalError: local variable 'x' referenced before assignment

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46612>
_______________________________________


More information about the Python-bugs-list mailing list