diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index db52f5ea08f..faedeee573c 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -693,7 +693,7 @@ This example shows how it all works:: StopIteration Having seen the mechanics behind the iterator protocol, it is easy to add -iterator behavior to your classes. Define a :meth:`__iter__` method which +iterator behavior to your classes. Define an :meth:`__iter__` method which returns an object with a :meth:`next` method. If the class defines :meth:`next`, then :meth:`__iter__` can just return ``self``:: @@ -710,7 +710,10 @@ returns an object with a :meth:`next` method. If the class defines self.index = self.index - 1 return self.data[self.index] - >>> for char in Reverse('spam'): + >>> rev = Reverse('spam') + >>> iter(rev) + <__main__.Reverse object at 0x00A1DB50> + >>> for char in rev: ... print char ... m