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 Eric.Wieser
Recipients Eric.Wieser, prudvinit, treddy
Date 2018-08-25.17:31:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535218295.44.0.56676864532.issue34494@psf.upfronthosting.co.za>
In-reply-to
Content
What I think I find surprising is that I'd expect the sequence protocol to be defined by `__getitem__` and `__len__`, and for `__iter__` to be inferred as:

    def __iter__(self):
        for i in range(len(self)):
            yield self[i]

But in reality it seems it is inferred only from `__getitem__`, as:

    def __iter__(self):
        i = 0
        while True:
            try:
                yield self[i]
            except IndexError:
                return
            i += 1
History
Date User Action Args
2018-08-25 17:31:35Eric.Wiesersetrecipients: + Eric.Wieser, prudvinit, treddy
2018-08-25 17:31:35Eric.Wiesersetmessageid: <1535218295.44.0.56676864532.issue34494@psf.upfronthosting.co.za>
2018-08-25 17:31:35Eric.Wieserlinkissue34494 messages
2018-08-25 17:31:35Eric.Wiesercreate