Commit 1a725102 authored by Georg Brandl's avatar Georg Brandl

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!
........
parent 79873805
...@@ -737,7 +737,7 @@ builtin; this example shows how it all works:: ...@@ -737,7 +737,7 @@ builtin; this example shows how it all works::
StopIteration StopIteration
Having seen the mechanics behind the iterator protocol, it is easy to add 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 returns an object with a :meth:`__next__` method. If the class defines
:meth:`__next__`, then :meth:`__iter__` can just return ``self``:: :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 ...@@ -754,7 +754,10 @@ returns an object with a :meth:`__next__` method. If the class defines
self.index = self.index - 1 self.index = self.index - 1
return self.data[self.index] 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) ... print(char)
... ...
m m
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment