[docs] [issue14528] Document whether strings implement __iter__

Chris Jerdonek report at bugs.python.org
Sun Apr 8 12:39:17 CEST 2012

Chris Jerdonek <chris.jerdonek at gmail.com> added the comment:

It is not "so important."  I just feel that the change should be acknowledged somewhere -- insofar as the existing user documentation on iterator types already discusses __iter__().  As it stands now, the Python 2 documentation is a bit misleading because it seems to suggest that strings implement __iter__().

With regard to falling back to __getitem__(), that might actually be worth mentioning in the section on iterator types.  Up until today, I didn't know there was a distinction between a "sequence protocol" and an "iterator protocol," as discussed here, for example--


For user code, the user might want different behavior depending on whether something behaves like a list.  For that, they might be relying on something like the presence of __iter__().


Python tracker <report at bugs.python.org>

More information about the docs mailing list