diff options
author | Georg Brandl <georg@python.org> | 2010-08-01 21:28:39 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-08-01 21:28:39 (GMT) |
commit | 57ebc910113957af2616988f1e4fa8af9d6f72a1 (patch) | |
tree | 53d057e31bae3c9600ca5fa7e1d7f0c63a53c6bc /Doc/tutorial | |
parent | 422b545852b0203a900044237c43cb50ac9b0b63 (diff) | |
download | cpython-57ebc910113957af2616988f1e4fa8af9d6f72a1.zip cpython-57ebc910113957af2616988f1e4fa8af9d6f72a1.tar.gz cpython-57ebc910113957af2616988f1e4fa8af9d6f72a1.tar.bz2 |
Merged revisions 82965 via svnmerge from
svn+ssh://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!
........
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/classes.rst | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index 27d0896..4c0c85a 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -737,7 +737,7 @@ builtin; 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``:: @@ -754,7 +754,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 |