diff options
author | Georg Brandl <georg@python.org> | 2010-08-01 21:28:47 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-08-01 21:28:47 +0000 |
commit | 2c10840e2c08265aa30b0c9c4996f84a3c761602 (patch) | |
tree | 555f0ca65c6aa0c1246ab0af648207d0aa7f6b72 /Doc/tutorial/classes.rst | |
parent | cde957af7476b228e7a8740ff61fcfdac28e34f8 (diff) | |
download | cpython-git-2c10840e2c08265aa30b0c9c4996f84a3c761602.tar.gz |
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!
........
Diffstat (limited to 'Doc/tutorial/classes.rst')
-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 db52f5ea08..faedeee573 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 |