nonlocal example
This commit is contained in:
parent
f27246a281
commit
59bd5291a7
12
python-temel/nonlocal.example.py
Normal file
12
python-temel/nonlocal.example.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
def foo():
|
||||
x = 10
|
||||
def bar():
|
||||
nonlocal x
|
||||
print(x)
|
||||
x += 1
|
||||
return bar
|
||||
|
||||
f = foo()
|
||||
f()
|
||||
f()
|
||||
f()
|
Loading…
Reference in New Issue
Block a user