Python · Concept
yield
A yield expression turns a function into a generator function. It pauses execution, returns a value, and later continues with preserved local state.
Last updated
- Since
- 2.5
Syntax
yield_expression ::= "yield" expression_list | yield_fromIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
generator functionsnext()send()throw()close()StopIterationGeneratorExit