Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 57ebc91

Browse files
committed
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! ........
1 parent 422b545 commit 57ebc91

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Doc/tutorial/classes.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ builtin; this example shows how it all works::
737737
StopIteration
738738

739739
Having seen the mechanics behind the iterator protocol, it is easy to add
740-
iterator behavior to your classes. Define a :meth:`__iter__` method which
740+
iterator behavior to your classes. Define an :meth:`__iter__` method which
741741
returns an object with a :meth:`__next__` method. If the class defines
742742
:meth:`__next__`, then :meth:`__iter__` can just return ``self``::
743743

@@ -754,7 +754,10 @@ returns an object with a :meth:`__next__` method. If the class defines
754754
self.index = self.index - 1
755755
return self.data[self.index]
756756

757-
>>> for char in Reverse('spam'):
757+
>>> rev = Reverse('spam')
758+
>>> iter(rev)
759+
<__main__.Reverse object at 0x00A1DB50>
760+
>>> for char in rev:
758761
... print(char)
759762
...
760763
m

0 commit comments

Comments
 (0)