python allows a nested function access outer scope code example
Example: python nested functions get variables from function scope
def a():
val = True
def b():
nonlocal val
val = False
def a():
val = True
def b():
nonlocal val
val = False