This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tutorial does not describe nested scope
Type: Stage:
Components: Documentation Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: fdrake, pierre_rouleau, rhettinger
Priority: high Keywords:

Created on 2002-01-08 03:27 by pierre_rouleau, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tut.diff rhettinger, 2002-08-05 15:33 Tutorial revision for release22-maint
Messages (5)
msg8643 - (view) Author: Pierre Rouleau (pierre_rouleau) Date: 2002-01-08 03:27
The current copy of the tuturial for Python 2.2 states, in chapter 9.2
(Python Scopes and Name Spaces):

"""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."""

I believe the above text should be updated to reflect the fact that Python 2.2 supports nested 
scopes.
msg8644 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-03-13 06:03
Logged In: YES 
user_id=3066

Bumped priority since this can cause real confusion for
someone learning Python.  The corrections need to be part of
Python 2.2.1 and the trunk.
msg8645 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-08-05 15:33
Logged In: YES 
user_id=80475

Patch attached for Fred's approval. If okay, re-assign to 
me and I'll make the same change to the trunk.
msg8646 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-08-07 15:17
Logged In: YES 
user_id=3066

It's probably worth noting that variables found in outer
non-scopes are read-only:

def outer():
    var = 1
    def inner():
        var = 2
    inner()
    print var

prints 1, not 2.

If you can add a note about that, you should be all set to
check in; no need for further review since I'll see the
checkin msg.

Thanks!
msg8647 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-08-07 16:10
Logged In: YES 
user_id=80475

Added note about read-only variables.
Commited as tut.tex versions 1.167 and 1.156.4.1.2.7
Marking as fixed and closing bug.
History
Date User Action Args
2022-04-10 16:04:51adminsetgithub: 35884
2002-01-08 03:27:01pierre_rouleaucreate