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