summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-07-19 11:28:05 (GMT)
committerGeorg Brandl <georg@python.org>2010-07-19 11:28:05 (GMT)
commit067425520e68073c991a8e750e008b23b2564c68 (patch)
tree1e5e6712006a0b33fac77e8a5e2d670ac2b95623 /Doc/tutorial
parent55353ca6dca62069cddde136be6f13ca374fce5b (diff)
downloadcpython-067425520e68073c991a8e750e008b23b2564c68.zip
cpython-067425520e68073c991a8e750e008b23b2564c68.tar.gz
cpython-067425520e68073c991a8e750e008b23b2564c68.tar.bz2
Clarification. Yay importlib!
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/classes.rst7
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 6b0efc3..da4d520 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -737,7 +737,7 @@ built-in function; 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