In python, I can write :
def func():
x = 1
print x
x+=1
def _func():
print x
return _func
test = func()
test()
Check this answer : https://stackoverflow.com/a/293097/1741450
Variables in scopes other than the local function's variables can be accessed, but can't be rebound to new parameters without further syntax. Instead, assignment will create a new local variable instead of affecting the variable in the parent scope. For example: