# File: global06.py # # b is considered defined in test() if there # is an assignment to b *anywhere* in test(). # If b is defined in test() after its first # use, then there is an "undefined value # error". # # It is *not* the case that b is global in # test() before it is defined # # Scope is lexical. Binding is dynamic. # def test() : print("b = ", b) b = 1 return b = 303 test() print("b = ", b) ''' Output from the program: Traceback (most recent call last): File "global06.py", line 21, in test() File "global06.py", line 16, in test print("b = ", b) UnboundLocalError: local variable 'b' referenced before assignment '''