Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

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.

----------
nosy: +josh.r

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34494>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to