ch01
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# Local, Enclosing and Global
|
||||
|
||||
|
||||
def enclosing_func():
|
||||
m = 13
|
||||
|
||||
def local():
|
||||
# m doesn't belong to the scope defined by the local
|
||||
# function so Python will keep looking into the next
|
||||
# enclosing scope. This time m is found in the enclosing
|
||||
# scope
|
||||
print(m, 'printing from the local scope')
|
||||
|
||||
# calling the function local
|
||||
local()
|
||||
|
||||
m = 5
|
||||
print(m, 'printing from the global scope')
|
||||
|
||||
enclosing_func()
|
||||
Reference in New Issue
Block a user