[issue45705] |= set update scoping

2021-11-03 Thread Steven D'Aprano
Change by Steven D'Aprano : -- stage: -> resolved ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue45705] |= set update scoping

2021-11-03 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: This is not a bug. You are getting an UnboundLocalError because in the scope of scoped_def function, scoped_dict is marked as local (because you assign to it in the function) but you are reading it before that. Please, take a look at: https://docs.p

[issue45705] |= set update scoping

2021-11-03 Thread James Bowery
James Bowery added the comment: My mistake. Disregard. -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Py

[issue45705] |= set update scoping

2021-11-03 Thread James Bowery
New submission from James Bowery : 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