mirror of
https://github.com/python/cpython.git
synced 2025-11-17 09:30:10 +00:00
#4992: next() method -> next() function.
This commit is contained in:
parent
115fb350fa
commit
6520d82fdf
1 changed files with 3 additions and 3 deletions
|
|
@ -441,14 +441,14 @@ statement in a function definition is sufficient to cause that definition to
|
||||||
create a generator function instead of a normal function.
|
create a generator function instead of a normal function.
|
||||||
When a generator function is called, it returns an iterator known as a generator
|
When a generator function is called, it returns an iterator known as a generator
|
||||||
iterator, or more commonly, a generator. The body of the generator function is
|
iterator, or more commonly, a generator. The body of the generator function is
|
||||||
executed by calling the generator's :meth:`next` method repeatedly until it
|
executed by calling the :func:`next` function on the generator repeatedly until
|
||||||
raises an exception.
|
it raises an exception.
|
||||||
|
|
||||||
When a :keyword:`yield` statement is executed, the state of the generator is
|
When a :keyword:`yield` statement is executed, the state of the generator is
|
||||||
frozen and the value of :token:`expression_list` is returned to :meth:`next`'s
|
frozen and the value of :token:`expression_list` is returned to :meth:`next`'s
|
||||||
caller. By "frozen" we mean that all local state is retained, including the
|
caller. By "frozen" we mean that all local state is retained, including the
|
||||||
current bindings of local variables, the instruction pointer, and the internal
|
current bindings of local variables, the instruction pointer, and the internal
|
||||||
evaluation stack: enough information is saved so that the next time :meth:`next`
|
evaluation stack: enough information is saved so that the next time :func:`next`
|
||||||
is invoked, the function can proceed exactly as if the :keyword:`yield`
|
is invoked, the function can proceed exactly as if the :keyword:`yield`
|
||||||
statement were just another external call.
|
statement were just another external call.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue