Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libstdtypes.tex @ 29590:8807e901c526 legacy-trunk
SF bug #696777: How to make a class iterable using a member generator.
* Added a note that a container class can implement the iterator protocol
by defining its __iter__() method as a generator.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Wed, 25 Jun 2003 19:03:22 +0000 |
| parents | d761ff55b3be |
| children | e9dddfd2a62f |
line wrap: on
line diff
--- a/Doc/lib/libstdtypes.tex Wed Jun 25 18:29:36 2003 +0000 +++ b/Doc/lib/libstdtypes.tex Wed Jun 25 19:03:22 2003 +0000 @@ -395,6 +395,12 @@ was added in Python 2.3; in Python 2.2, various iterators are broken according to this rule.) +Python's generators provide a convenient way to implement the +iterator protocol. If a container object's \method{__iter__()} +method is implemented as a generator, it will automatically +return an iterator object (technically, a generator object) +supplying the \method{__iter__()} and \method{next()} methods. + \subsection{Sequence Types \label{typesseq}}
