msg231529 - (view) |
Author: Éric Araujo (eric.araujo) *  |
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) *  |
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) *  |
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) *  |
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) *  |
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) *  |
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) *  |
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)  |
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) *  |
Date: 2014-12-10 14:52 |
Thanks, Chaitanya. |
|
|