Ammar Askar added the comment:
Take a look at
https://docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value
What's happening is that because `a |= x` is treated as an assignment, i.e `a =
a | x`. The compiler treats it as a local variable,
New submission from Gabriele Tornetta :
def outer():
a=set()
def inner():
a |= set(["A"])
inner()
return a
print(outer())
Traceback (most recent call last):
File "main.py", line 8, in
print(outer())
File "main.py", line 5, in outer
inner()
File "main.py", line 4, in