foo.bar.nonlocal example
This commit is contained in:
parent
c6f5c580a3
commit
c8bb84641a
12
python-temel/foo.bar.nonlocal.py
Normal file
12
python-temel/foo.bar.nonlocal.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
def foo():
|
||||
x = 10
|
||||
def bar():
|
||||
nonlocal x # foo'daki x
|
||||
x = 20
|
||||
def tar():
|
||||
nonlocal x # bar'daki x
|
||||
x = 30
|
||||
tar()
|
||||
bar()
|
||||
print(x) # 30
|
||||
foo()
|
12
python-temel/foo.bar.nonlocal.py~
Normal file
12
python-temel/foo.bar.nonlocal.py~
Normal file
|
@ -0,0 +1,12 @@
|
|||
def foo():
|
||||
x = 10
|
||||
def bar():
|
||||
nonlocal x # foo'daki
|
||||
x = 20
|
||||
def tar():
|
||||
nonlocal x # bar'daki x
|
||||
x = 30
|
||||
tar()
|
||||
bar()
|
||||
print(x)
|
||||
foo()
|
Loading…
Reference in New Issue
Block a user