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 hiba
Recipients docs@python, hiba
Date 2017-06-22.17:19:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498151952.1.0.340362281065.issue30738@psf.upfronthosting.co.za>
In-reply-to
Content
class Reverse:
    """Iterator for looping over a sequence backwards."""
    def __init__(self, data):
        self.data = data
        self.index = len(data)

    def __iter__(self):
        return self

    def next(self):
        if self.index == 0:
            raise StopIteration
        self.index = self.index - 1
        return self.data[self.index]


*********************************************
The next() method in the above code snippet(from 9.9 Iterators section in Tutorial is not correctly overridden. It's missing the underscores.
History
Date User Action Args
2017-06-22 17:19:12hibasetrecipients: + hiba, docs@python
2017-06-22 17:19:12hibasetmessageid: <1498151952.1.0.340362281065.issue30738@psf.upfronthosting.co.za>
2017-06-22 17:19:12hibalinkissue30738 messages
2017-06-22 17:19:11hibacreate