scoping problem in recursive closure
- by wiso
why this work:
def function1():
a = 10
def function2():
print a
function2()
but this not:
def function1():
a = 10
def function2():
print a
a -= 1
if a>0:
function2()
function2()
error:
UnboundLocalError: local variable 'a' referenced before assignment