[issue26683] Questionable terminology for describing what locals() does

Terry J. Reedy report at bugs.python.org
Fri Apr 1 14:24:59 EDT 2016


Terry J. Reedy added the comment:

I requested that we stop (mis)using 'free variable' in the docs years ago.  A strong +1 from me.

The 'locals' function what named when 'local' and 'non-global' were synonyms.  When non-local, non-global names were added, nonlocals were included with 'locals' as 'non-global'.  (This must have been thought to be more useful than adding nonlocals() or excluding them.)

They are, of course, local in some surrounding non-global context.  And for most purposes, their entries in locals() should also be treated as read-only.  I think the doc should say that function locals() includes the locals of surrounding function contexts, even though they are called 'nonlocal' within the nested function.

----------
nosy: +terry.reedy

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


More information about the Python-bugs-list mailing list