New submission from Terry J. Reedy <[email protected]>: Doc for locals(): after correctly stating "Update and return a dictionary representing the current local symbol table.
Note The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter." current doc goes on to say "Free variables are returned by locals() when it is called in a function block. Modifications of free variables may not affect the values used by the interpreter. Free variables are not returned in class blocks." As best I can understand this, it is wrong and should be removed. Free variables within a function block are global/nonlocal names and by my experimentation with 3.1, (including lambda expressions) are NOT returned by locals(). If it means something else, it needs a rewrite. The doc for var() starts "Without arguments, return a dictionary corresponding to the current local symbol table." I suggest augmenting this with 'update and ' (to match locals doc) and '(same as locals())' to make that fact clear (as it is with help(vars)), even though removing the 'Free variables' stuff will help the latter clearer also. The result would be Without arguments, update and return a dictionary corresponding to the current local symbol table (same as locals()). ---------- messages: 92728 nosy: tjreedy severity: normal status: open title: Doc for locals and vars versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2 _______________________________________ Python tracker <[email protected]> <http://bugs.python.org/issue6925> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
