@@ -3551,12 +3551,17 @@ \section{Python Scopes and Name Spaces \label{scopes}}
35513551the namespace.
35523552
35533553Although 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
35613566Usually, the local scope references the local names of the (textually)
35623567current function. Outside of functions, the local scope references
0 commit comments