mirror of
https://github.com/python/cpython.git
synced 2026-01-22 23:28:43 +00:00
Add :term: for generators.
This commit is contained in:
parent
bb75e4e5d2
commit
cf3fb25932
17 changed files with 47 additions and 46 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue