a=1
def func():
print(a)
a=2
func()
The code above issues the following error:
local variable 'a' referenced before assignment
Given the imperative nature of Python i expect that the variable a
is treated like a global variable before the Interpreter reaches the next line, where the variable a
is assigned again but as a local variable (since it happens inside the function).