This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Slightly modify locals() doc?
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, terry.reedy
Priority: normal Keywords:

Created on 2002-12-17 16:46 by terry.reedy, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (2)
msg13654 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2002-12-17 16:46
Lib ref manual 2.1 builtin funcs: locals() says
"Return a dictionary representing the current local 
symbol table"
This can be (and has been, by experience users) 
interpreted as "return a *new* dictionary..."

It would better describe current behavior if it said:
"Update and return the dictionary...." 
This would make the following less surprising:

>>> def f():
...   foo = 'bar'
...   a = locals()
...   a['foo'] = 'Guido'
...   try: print a['a']
...   except: print "'a' is not in a"
...   print a['foo'], locals()['foo'], a['foo'], a['a']
...
>>> f()
'a' is not in a
Guido bar bar {'a': {...}, 'foo': 'bar'}


msg13655 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-01-04 02:18
Logged In: YES 
user_id=80475

Applied as libfuncs.tex 1.127 and bltinmodule.c 2.270.
Closing bug.
History
Date User Action Args
2022-04-10 16:06:02adminsetgithub: 37625
2002-12-17 16:46:54terry.reedycreate