[Python-checkins] r82965 - python/branches/py3k/Doc/tutorial/classes.rst
georg.brandl
python-checkins at python.org
Mon Jul 19 13:28:05 CEST 2010
Author: georg.brandl
Date: Mon Jul 19 13:28:05 2010
New Revision: 82965
Log:
Clarification. Yay importlib!
Modified:
python/branches/py3k/Doc/tutorial/classes.rst
Modified: python/branches/py3k/Doc/tutorial/classes.rst
==============================================================================
--- python/branches/py3k/Doc/tutorial/classes.rst (original)
+++ python/branches/py3k/Doc/tutorial/classes.rst Mon Jul 19 13:28:05 2010
@@ -737,7 +737,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``::
@@ -754,7 +754,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
More information about the Python-checkins
mailing list