FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learn-python/scope.py at master · ringlog/learn-python · GitHub
ringlog
/
learn-python
Public
forked from
tanteng/learn-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
learn-python
/
scope.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (31 loc) · 716 Bytes
Breadcrumbs
learn-python
/
scope.py
Copy path
File metadata and controls
36 lines (31 loc) · 716 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
def
scope_test
():
def
do_local
():
spam
=
"local spam"
def
do_nonlocal
():
nonlocal
spam
spam
=
"nonlocal spam"
def
do_global
():
global
spam
spam
=
"global spam"
spam
=
"test spam"
do_local
()
print
(
"After local assignment:"
,
spam
)
do_nonlocal
()
print
(
"After nonlocal assignment:"
,
spam
)
do_global
()
print
(
"After global assignment:"
,
spam
)
scope_test
()
print
(
"In global scope:"
,
spam
)
def
make_counter
():
count
=
0
def
counter
():
nonlocal
count
count
+=
1
return
count
return
counter
def
make_counter_test
():
mc
=
make_counter
()
print
(
mc
())
print
(
mc
())
print
(
mc
())
make_counter_test
()
Back
|
FazBrowse Home
|
New Git URL