[issue14528] Document whether strings implement __iter__
report at bugs.python.org
Sun Apr 8 12:05:38 CEST 2012
New submission from Chris Jerdonek <chris.jerdonek at gmail.com>:
While converting code from Python 2 to Python 3, I came across the "gotcha" that strings implement __iter__ in Python 3 but not in Python 2.
Looking through the documentation, I don't seem to see anything like this mentioned in the library portion of either Python 2 or 3's documentation:
Or in the documentation describing differences between 2 and 3:
In fact, the Python 2 and 3 sections on iterator types seem largely the same. Python 2's documentation even seems a bit misleading in this regard. At the beginning of this section, it says, "Sequences, described below in more detail, always support the iteration methods [of which __iter__() is the main one]." And str and unicode are the first two types mentioned in that next section on sequence types.
Here is a blog post I came across about this issue:
I think it would be worth highlighting this issue somewhere in the Python documentation, or at least acknowledging the change (unless I'm simply looking in the wrong place, in which case maybe it should be made more visible).
assignee: docs at python
nosy: cjerdonek, docs at python
title: Document whether strings implement __iter__
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list