[docs] [issue28853] locals() and free variables

Julien Palard report at bugs.python.org
Fri Dec 2 09:21:40 EST 2016

Julien Palard added the comment:

Hi, thanks for reporting,

Variables are defined in python docs¹ by:

> If a name is bound in a block, it is a local variable of that block, unless declared as nonlocal or global. If a name is bound at the module level, it is a global variable. (The variables of the module code block are local and global.) If a variable is used in a code block but not defined there, it is a free variable.

According to this definition, global variables used in a code block are free variable, is this intentional? I think so, but can't be sure, maybe someone is seeing this as "globals are NOT free variables", in this case, this definition should probably be enhanced.

If I'm right, maybe we should just change "Free variables are returned"… to "Non-global free variables are returned"…?

nosy: +mdk

Python tracker <report at bugs.python.org>

More information about the docs mailing list