According to the Python documentation the yield keyword can take an "expression_list", but it is optional:
yield_expression ::= "yield" [expression_list]
I can find no examples of such usage, either in the Python docs, in any of the answers to What does the yield keyword do in Python, nor from generally reading around the web.
If yield
is used without an expression_list
then I guess that the resulting method cannot be useful as a generator, so are there other scenarios where a plain yield
might be useful?