Documentation
The wording in section 3.2.8.3 is potentially misleading:
“A function or method which uses the yield statement … is called a generator function.”
and later:
“the function … provides a value using the yield statement.”
yield is not necessarily a yield statement (yield_stmt in the grammar). It can also occur as part of an expression, for example:
Here yield 5 is a yield expression, but f is still a generator function.
It may be more accurate to refer to a function that contains a yield expression rather than one that “uses the yield statement”.
Linked PRs
Documentation
The wording in section 3.2.8.3 is potentially misleading:
and later:
yield is not necessarily a yield statement (yield_stmt in the grammar). It can also occur as part of an expression, for example:
Here yield 5 is a yield expression, but f is still a generator function.
It may be more accurate to refer to a function that contains a yield expression rather than one that “uses the yield statement”.
Linked PRs