-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScope_function.py
53 lines (45 loc) · 961 Bytes
/
Scope_function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# def check_scope():
# def do_local():
# test='A test'
# print('a :',test)
# def do_non_local():
# nonlocal test
# test='B test'
# def do_global():
# global test
# test='C global'
# def loca():
# test='goal'
#
# test='default local'
# do_local()
# print('hiiiii : ',test)
# do_non_local()
# print('heyyyy : ',test)
# do_global()
# print('hoiiii',test)
# loca()
# print('hiddddididd',test)
#
# check_scope()
# print('main : ',test)
#------------------------------------------------------
def main():
def A():
test='Test A'
# print('value :',test)
def B():
nonlocal test
test='Test B'
def C():
global test
test='Test C'
test='General Test'
A()
print('value 1 : ',test)
B()
print('value 2 : ',test)
C()
print('value 3 : ',test)
main()
print('value 4 : ',test)