[issue6925] Doc for locals and vars

Georg Brandl report at bugs.python.org
Sat Sep 19 12:35:10 CEST 2009


Georg Brandl <georg at python.org> added the comment:

> I disagree with calling only nonlocal variables but not module variables
> 'free'. As I quoted from Wikipedia, that restrictive definition is not
> agree on by all at all.

But it is the definition that Python uses, at least in the code.  I
agree that the usage of "free variable" in the reference manual is
inconsistent; this should be fixed independently.

> Python does not treat top-level or recursive function names specially in
> the way meant above.

It does treat them differently: they are globals, not free variables.

> I used 'nonlocal' specifically because the behavior of locals() seemed
> by my testing to be concordant with the behavior of the 'nonlocal'
> statement, which rejects the globals that locals does not print.  What
> do you mean by 'clash'?

"nonlocal" variables could be mistaken as variables that are declared as
nonlocal by such a statement.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6925>
_______________________________________


More information about the Python-bugs-list mailing list