Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9aa643cf
Commit
9aa643cf
authored
Mar 01, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test interaction of global and nested scopes -- thanks to Samuele Pedroni.
parent
7606e4d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
Lib/test/output/test_scope
Lib/test/output/test_scope
+1
-0
Lib/test/test_scope.py
Lib/test/test_scope.py
+65
-0
No files found.
Lib/test/output/test_scope
View file @
9aa643cf
...
...
@@ -13,3 +13,4 @@ test_scope
12. lambdas
13. UnboundLocal
14. complex definitions
15. scope of global statements
Lib/test/test_scope.py
View file @
9aa643cf
...
...
@@ -318,3 +318,68 @@ def makeAddPair((a, b)):
return
addPair
verify
(
makeAddPair
((
1
,
2
))((
100
,
200
))
==
(
101
,
202
))
print
"15. scope of global statements"
# Examples posted by Samuele Pedroni to python-dev on 3/1/2001
# I
x
=
7
def
f
():
x
=
1
def
g
():
global
x
def
i
():
def
h
():
return
x
return
h
()
return
i
()
return
g
()
verify
(
f
()
==
7
)
verify
(
x
==
7
)
# II
x
=
7
def
f
():
x
=
1
def
g
():
x
=
2
def
i
():
def
h
():
return
x
return
h
()
return
i
()
return
g
()
verify
(
f
()
==
2
)
verify
(
x
==
7
)
# III
x
=
7
def
f
():
x
=
1
def
g
():
global
x
x
=
2
def
i
():
def
h
():
return
x
return
h
()
return
i
()
return
g
()
verify
(
f
()
==
2
)
verify
(
x
==
2
)
# IV
x
=
7
def
f
():
x
=
3
def
g
():
global
x
x
=
2
def
i
():
def
h
():
return
x
return
h
()
return
i
()
return
g
()
verify
(
f
()
==
2
)
verify
(
x
==
2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment