Mercurial > cpython-lru_cache-weakref
diff Doc/tutorial/classes.rst @ 63491:27544fb0f7f1 2.7
Merged revisions 82965 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r82965 | georg.brandl | 2010-07-19 13:28:05 +0200 (Mo, 19 Jul 2010) | 1 line
Clarification. Yay importlib!
........
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 01 Aug 2010 21:28:47 +0000 |
| parents | a10a7ce97f45 |
| children | 595676e466c0 |
line wrap: on
line diff
--- a/Doc/tutorial/classes.rst Sun Aug 01 21:27:58 2010 +0000 +++ b/Doc/tutorial/classes.rst Sun Aug 01 21:28:47 2010 +0000 @@ -693,7 +693,7 @@ 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 @@ 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
