KA
Size: a a a
KA
JN
S
KA
JN
S
py3
help("yield")
The "yield" statement
*********************
yield_stmt ::= yield_expression
A "yield" statement is semantically equivalent to a yield expression.
The yield statement can be used to omit the parentheses that would
otherwise be required in the equivalent yield expression statement.
For example, the yield statements
yield <expr>
yield from <expr>
are equivalent to the yield expression statements
(yield <expr>)
(yield from <expr>)
Yield expressions and statements are only used when defining a
*generator* function, and are only used in the body of the generator
function. Using yield in a function definition is sufficient to cause
that definition to create a generator function instead of a normal
function.
For full details of "yield" semantics, refer to the Yield expressions
section.
KA
S
py3
help("yield")
The "yield" statement
*********************
yield_stmt ::= yield_expression
A "yield" statement is semantically equivalent to a yield expression.
The yield statement can be used to omit the parentheses that would
otherwise be required in the equivalent yield expression statement.
For example, the yield statements
yield <expr>
yield from <expr>
are equivalent to the yield expression statements
(yield <expr>)
(yield from <expr>)
Yield expressions and statements are only used when defining a
*generator* function, and are only used in the body of the generator
function. Using yield in a function definition is sufficient to cause
that definition to create a generator function instead of a normal
function.
For full details of "yield" semantics, refer to the Yield expressions
section.
S
py3
help("keywords")
Here is a list of the Python keywords. Enter any keyword to get more help.
False def if raise
None del import return
True elif in try
and else is while
as except lambda with
assert finally nonlocal yield
break for not
class from or
continue global pass
ダ
Yield это ключевое слово, которое используется примерно как return — отличие в том, что функция вернёт генератор. В данном случае пример бесполезный, но это удобно, если вы знаете, что функция вернёт большой набор значений, который надо будет прочитать только один раз.
S
py3
help("keywords")
Here is a list of the Python keywords. Enter any keyword to get more help.
False def if raise
None del import return
True elif in try
and else is while
as except lambda with
assert finally nonlocal yield
break for not
class from or
continue global pass
KA
KA
т
ダ
JN
Yield это ключевое слово, которое используется примерно как return — отличие в том, что функция вернёт генератор. В данном случае пример бесполезный, но это удобно, если вы знаете, что функция вернёт большой набор значений, который надо будет прочитать только один раз.
JN
ダ
ダ