value = "global"
def pr():
print("value scope: ", value)
def ex1():
def f():
def f():
pr()
f()
f()
def ex2():
value = "outer local"
def f():
def f():
pr()
f()
f()
def ex3():
def f():
value = "inner local"
def f():
pr()
f()
f()
def ex4():
def f():
def f():
value = "very local"
pr()
f()
f()
ex1()
ex2()
ex3()
ex4()
dmFsdWUgPSAiZ2xvYmFsIgoKZGVmIHByKCk6CglwcmludCgidmFsdWUgc2NvcGU6ICIsIHZhbHVlKQoKZGVmIGV4MSgpOgoJZGVmIGYoKToKCQlkZWYgZigpOgoJCQlwcigpCgkJZigpCglmKCkKCmRlZiBleDIoKToKCXZhbHVlID0gIm91dGVyIGxvY2FsIgoJZGVmIGYoKToKCQlkZWYgZigpOgoJCQlwcigpCgkJZigpCglmKCkKCmRlZiBleDMoKToKCWRlZiBmKCk6CgkJdmFsdWUgPSAiaW5uZXIgbG9jYWwiCgkJZGVmIGYoKToKCQkJcHIoKQoJCWYoKQoJZigpCgpkZWYgZXg0KCk6CglkZWYgZigpOgoJCWRlZiBmKCk6CgkJCXZhbHVlID0gInZlcnkgbG9jYWwiCgkJCXByKCkKCQlmKCkKCWYoKQoJCmV4MSgpCmV4MigpCmV4MygpCmV4NCgp