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
861bb024
Commit
861bb024
authored
Aug 07, 2002
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Describe nested scopes in the tutorial. Closes SF bug 500704.
parent
29bf9157
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
Doc/tut/tut.tex
Doc/tut/tut.tex
+11
-6
No files found.
Doc/tut/tut.tex
View file @
861bb024
...
...
@@ -3551,12 +3551,17 @@ that an unqualified reference to a name attempts to find the name in
the namespace.
Although scopes are determined statically, they are used dynamically.
At any time during execution, exactly three nested scopes are in use
(exactly three namespaces are directly accessible): the
innermost scope, which is searched first, contains the local names,
the middle scope, searched next, contains the current module's global
names, and the outermost scope (searched last) is the namespace
containing built-in names.
At any time during execution, there are at least three nested scopes whose
namespaces are directly accessible: the innermost scope, which is searched
first, contains the local names; the namespaces of any enclosing code
blocks (a module, function, or class definition) which are searched starting
with the nearest enclosing scope; the middle scope, searched next, contains
the current module's global names; and the outermost scope (searched last)
is the namespace containing built-in names.
If a name is declared global, then all references and assignments go
directly to the middle scope containing the module's global names.
Otherwise, all variables found outside of the innermost scope are read-only.
Usually, the local scope references the local names of the (textually)
current function. Outside of functions, the local scope references
...
...
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