[issue22918] Doc for __iter__ makes inexact comment about dict.__iter__

New submission from Éric Araujo:
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()).
---------- assignee: docs@python components: Documentation keywords: easy messages: 231529 nosy: docs@python, eric.araujo priority: normal severity: normal stage: needs patch status: open title: Doc for __iter__ makes inexact comment about dict.__iter__ versions: Python 3.4, Python 3.5
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

R. David Murray added the comment:
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".
---------- nosy: +r.david.murray
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

Éric Araujo added the comment:
The Python 2 doc is alright, the same line says that d.__iter__() is equivalent to d.iterkeys().
----------
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

R. David Murray added the comment:
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.
----------
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

Éric Araujo added the comment:
I think the first half of the sentence is enough: “For mappings, it should iterate over the keys of the container.”
----------
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

Terry J. Reedy added the comment:
Since .iterkeys is gone, I thing the ', and' part should just be dropped.
---------- nosy: +terry.reedy
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

Raymond Hettinger added the comment:
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 :-)
---------- nosy: +rhettinger
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

Changes by Chaitanya agrawal chaitiagrawal@gmail.com:
---------- keywords: +patch Added file: http://bugs.python.org/file37407/issue22918-inexactComment.diff
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

Roundup Robot added the comment:
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
---------- nosy: +python-dev
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________

R. David Murray added the comment:
Thanks, Chaitanya.
---------- resolution: -> fixed stage: needs patch -> resolved status: open -> closed type: -> behavior
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue22918 _______________________________________
participants (6)
-
Chaitanya agrawal
-
R. David Murray
-
Raymond Hettinger
-
Roundup Robot
-
Terry J. Reedy
-
Éric Araujo