New text about "from __future__ import generators".
This commit is contained in:
parent
1c2f3d4697
commit
67c021817d
13
pep-0255.txt
13
pep-0255.txt
|
@ -125,10 +125,15 @@ Specification: Yield
|
|||
yield_stmt: "yield" expression_list
|
||||
|
||||
"yield" is a new keyword, so a future statement[8] is needed to phase
|
||||
this in. [XXX spell this out -- but new keywords have ripple effects
|
||||
across tools too, and it's not clear this can be forced into the future
|
||||
framework at all -- it's not even clear that Python's parser alone can
|
||||
be taught to swing both ways based on a future stmt]
|
||||
this in: in the initial release, a module desiring to use generators
|
||||
must include the line
|
||||
|
||||
from __future__ import generators
|
||||
|
||||
near the top (see PEP 236[8]) for details). Modules using the
|
||||
identifier "yield" without a future statement will trigger warnings.
|
||||
In the following release, yield will be a language keyword and the
|
||||
future statement will no longer be needed.
|
||||
|
||||
The yield statement may only be used inside functions. A function that
|
||||
contains a yield statement is called a generator function. A generator
|
||||
|
|
Loading…
Reference in New Issue