def test var None def inner var var or test return var return inner te

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
>>> def test(var=None):
... def inner():
... var = var or 'test'
... return var
... return inner
...
>>> test()()
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
/Users/piranha/<ipython console> in <module>()
/Users/piranha/<ipython console> in inner()
UnboundLocalError: local variable 'var' referenced before assignment