Quick actions

cmd+k|ctrl+k

Navigation

Languages

Scoping Ex.1

Snippet info

Language

Python

Visibility

public

Author

chausage

Created

2025-01-20T01:22:40.974307Z

Updated

2025-01-20T02:24:33.97653Z

x=1
y=2
def a():
    global x
    z=1
    def inner():
        nonlocal z
        z=z+1 #z is closure
        x=z+1
        print (x)
        print (z)
    x=y+1
    return inner
def b():
    global x
    c = a()
    y=1
    x=x+2
    c()
outer_func = a()
outer_func()
outer_func()
b()
INFO