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 josh.r
Recipients Eric.Wieser, josh.r, prudvinit, rhettinger, treddy
Date 2018-08-26.14:43:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535294623.33.0.56676864532.issue34494@psf.upfronthosting.co.za>
In-reply-to
Content
That's the documented behavior. Per https://docs.python.org/3/reference/datamodel.html#object.__getitem__ :

>Note: for loops expect that an IndexError will be raised for illegal indexes to allow proper detection of the end of the sequence. 

The need for *only* __getitem__ is also mentioned in the documentation of the iter builtin ( https://docs.python.org/3/library/functions.html#iter ):

>Without a second argument, object must be a collection object which supports the iteration protocol (the __iter__() method), or it must support the sequence protocol (the __getitem__() method with integer arguments starting at 0).

At no point is a dependency on __len__ mentioned.
History
Date User Action Args
2018-08-26 14:43:43josh.rsetrecipients: + josh.r, rhettinger, Eric.Wieser, prudvinit, treddy
2018-08-26 14:43:43josh.rsetmessageid: <1535294623.33.0.56676864532.issue34494@psf.upfronthosting.co.za>
2018-08-26 14:43:43josh.rlinkissue34494 messages
2018-08-26 14:43:43josh.rcreate