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: Doc for __iter__ makes inexact comment about dict.__iter__
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eric.araujo, python-dev, r.david.murray, rhettinger, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2014-11-22 20:49 by eric.araujo, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue22918-inexactComment.diff krypten, 2014-12-10 10:51 File for resolving issue 22918. Second half of comment sentence removed as stated in messages. review
Messages (9)
msg231529 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-11-22 20:49
https://docs.python.org/3/reference/datamodel#object.__iter__

> This method should return a new iterator object that can iterate over all the objects
> in the container. For mappings, it should iterate over the keys of the container, and
> should also be made available as the method keys().

In 3.x, d.__iter__() is not equivalent to d.keys() but to iter(d.keys()).
msg231536 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-11-22 22:36
They aren't equivalent in python2, either.  I think probably the wording should be changed to something like "and the method keys() should return an iterable that provides access to the same data".
msg231543 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-11-23 01:05
The Python 2 doc is alright, the same line says that d.__iter__() is equivalent to d.iterkeys().
msg231546 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-11-23 05:49
Ah, I see.  So the python3 docs should say "and should be equivalent to iter(dict.keys())" ?  Or maybe the whole phrase should just be dropped.
msg231571 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-11-23 16:57
I think the first half of the sentence is enough: “For mappings, it should iterate over the keys of the container.”
msg231843 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-11-29 00:25
Since .iterkeys is gone, I thing the ', and' part should just be dropped.
msg232361 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-12-09 10:18
> I think the first half of the sentence is enough: 
> “For mappings, it should iterate over the keys of the container.”

That should do it :-)
msg232428 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-12-10 14:51
New changeset 743ebaba14db by R David Murray in branch '3.4':
#22918: Drop obsolete mention of 'keys' in datamodel __iter__ docs.
https://hg.python.org/cpython/rev/743ebaba14db

New changeset 1a1f577ca647 by R David Murray in branch 'default':
Merge: #22918: Drop obsolete mention of 'keys' in datamodel __iter__ docs.
https://hg.python.org/cpython/rev/1a1f577ca647
msg232429 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-12-10 14:52
Thanks, Chaitanya.
History
Date User Action Args
2022-04-11 14:58:10adminsetgithub: 67107
2014-12-10 14:52:41r.david.murraysetstatus: open -> closed
type: behavior
messages: + msg232429

resolution: fixed
stage: needs patch -> resolved
2014-12-10 14:51:48python-devsetnosy: + python-dev
messages: + msg232428
2014-12-10 10:51:40kryptensetfiles: + issue22918-inexactComment.diff
keywords: + patch
2014-12-09 10:18:56rhettingersetnosy: + rhettinger
messages: + msg232361
2014-11-29 00:25:50terry.reedysetnosy: + terry.reedy
messages: + msg231843
2014-11-23 16:57:49eric.araujosetmessages: + msg231571
2014-11-23 05:49:55r.david.murraysetmessages: + msg231546
2014-11-23 01:05:39eric.araujosetmessages: + msg231543
2014-11-22 22:36:32r.david.murraysetnosy: + r.david.murray
messages: + msg231536
2014-11-22 20:49:39eric.araujocreate