New submission from Martijn Pieters:

>From the 9.2. Python Scopes and Namespace section:

> If a name is declared global, then all references and assignments go directly 
> to the middle scope containing the module’s global names. To rebind variables 
> found outside of the innermost scope, the nonlocal statement can be used; if 
> not declared nonlocal, those variable are read-only (an attempt to write to 
> such a variable will simply create a new local variable in the innermost 
> scope, leaving the identically named outer variable unchanged).

This terminology is extremely confusing to newcomers; see 
https://stackoverflow.com/questions/35667757/read-only-namespace-in-python for 
an example. Variables are never read-only. The parent scope name simply is *not 
visible*, which is an entirely different concept. Can this section be 
re-written to not use the term 'read-only'?

----------
messages: 260933
nosy: mjpieters
priority: normal
severity: normal
status: open
title: Tutorial on Python Scopes and Namespaces uses confusing 'read-only' 
terminology

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26449>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to