nonlocal and variable
This commit is contained in:
parent
247ebeb4e5
commit
a5d6ac70f4
11
python-temel/nonlocal.variable.py
Normal file
11
python-temel/nonlocal.variable.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
x = 10
|
||||
|
||||
def foo():
|
||||
def bar():
|
||||
#nonlocal x #error!
|
||||
#print(x)
|
||||
x = 20
|
||||
print(x)
|
||||
bar()
|
||||
|
||||
foo()
|
11
python-temel/nonlocal.variable.py~
Normal file
11
python-temel/nonlocal.variable.py~
Normal file
|
@ -0,0 +1,11 @@
|
|||
x = 10
|
||||
|
||||
def foo():
|
||||
def bar():
|
||||
nonlocal x #error!
|
||||
print(x)
|
||||
x = 20
|
||||
print(x)
|
||||
bar()
|
||||
|
||||
foo()
|
Loading…
Reference in New Issue
Block a user