Message405643
Comment out the |= line and it prints "{'b':2}" as expected.
$ cat t.py
scoped_dict = {'b':2}
def scoped_def():
print(scoped_dict)
scoped_dict |= {'a',1}
scoped_def()
$ p t.py
Traceback (most recent call last):
File "/home/jabowery/dev/t.py", line 5, in <module>
scoped_def()
File "/home/jabowery/dev/t.py", line 3, in scoped_def
print(scoped_dict)
UnboundLocalError: local variable 'scoped_dict' referenced before assignment
$ python --version
Python 3.10.0 |
|
Date |
User |
Action |
Args |
2021-11-03 20:24:40 | jabowery2 | set | recipients:
+ jabowery2, lys.nikolaou, pablogsal |
2021-11-03 20:24:40 | jabowery2 | set | messageid: <1635971080.35.0.70243315955.issue45705@roundup.psfhosted.org> |
2021-11-03 20:24:40 | jabowery2 | link | issue45705 messages |
2021-11-03 20:24:40 | jabowery2 | create | |
|