Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 861bb02

Browse files
committed
Describe nested scopes in the tutorial. Closes SF bug 500704.
1 parent 29bf915 commit 861bb02

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

Doc/tut/tut.tex

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,12 +3551,17 @@ \section{Python Scopes and Name Spaces \label{scopes}}
35513551
the namespace.
35523552
35533553
Although scopes are determined statically, they are used dynamically.
3554-
At any time during execution, exactly three nested scopes are in use
3555-
(exactly three namespaces are directly accessible): the
3556-
innermost scope, which is searched first, contains the local names,
3557-
the middle scope, searched next, contains the current module's global
3558-
names, and the outermost scope (searched last) is the namespace
3559-
containing built-in names.
3554+
At any time during execution, there are at least three nested scopes whose
3555+
namespaces are directly accessible: the innermost scope, which is searched
3556+
first, contains the local names; the namespaces of any enclosing code
3557+
blocks (a module, function, or class definition) which are searched starting
3558+
with the nearest enclosing scope; the middle scope, searched next, contains
3559+
the current module's global names; and the outermost scope (searched last)
3560+
is the namespace containing built-in names.
3561+
3562+
If a name is declared global, then all references and assignments go
3563+
directly to the middle scope containing the module's global names.
3564+
Otherwise, all variables found outside of the innermost scope are read-only.
35603565
35613566
Usually, the local scope references the local names of the (textually)
35623567
current function. Outside of functions, the local scope references

0 commit comments

Comments
 (0)