Add :term: for generators.

This commit is contained in:
Georg Brandl 2007-10-21 10:52:38 +00:00
parent bb75e4e5d2
commit cf3fb25932
17 changed files with 47 additions and 46 deletions

View file

@ -711,12 +711,12 @@ returns an object with a :meth:`next` method. If the class defines
Generators
==========
Generators are a simple and powerful tool for creating iterators. They are
written like regular functions but use the :keyword:`yield` statement whenever
they want to return data. Each time :meth:`next` is called, the generator
resumes where it left-off (it remembers all the data values and which statement
was last executed). An example shows that generators can be trivially easy to
create::
:term:`Generator`\s are a simple and powerful tool for creating iterators. They
are written like regular functions but use the :keyword:`yield` statement
whenever they want to return data. Each time :meth:`next` is called, the
generator resumes where it left-off (it remembers all the data values and which
statement was last executed). An example shows that generators can be trivially
easy to create::
def reverse(data):
for index in range(len(data)-1, -1, -1):