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.

Author rhettinger
Recipients docs@python, methane, rhettinger
Date 2010-11-13.23:51:22
SpamBayes Score 4.9359416e-05
Marked as misclassified No
Message-id <1289692285.61.0.112137812002.issue10410@psf.upfronthosting.co.za>
In-reply-to
Content
> "iterable" is described as "A container object 
> capable of returning its members one at a time."

That wording is confusing.  I'll fix it.

> Likewise, "and objects of any classes you define 
> with an __iter__() or __getitem__() method." is 
> wrong because __getitem__ method is not relate to
> iterable

That wording is correct.  Sequences are automatically
iterable even if they don't define __iter__.  For example:

>>> class A:
...     def __getitem__(self, i):
...         if i > 10:
...             raise IndexError(i)
...         return i * 100
	
>>> list(A())
[0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]

If you're curious, the details are in the PyObject_GetIter() function in http://svn.python.org/view/python/branches/release27-maint/Objects/abstract.c?view=markup .
History
Date User Action Args
2010-11-13 23:51:25rhettingersetrecipients: + rhettinger, methane, docs@python
2010-11-13 23:51:25rhettingersetmessageid: <1289692285.61.0.112137812002.issue10410@psf.upfronthosting.co.za>
2010-11-13 23:51:22rhettingerlinkissue10410 messages
2010-11-13 23:51:22rhettingercreate