Skip to content

Inaccurate terminology in the “Generator functions” section #156837

Description

@dluschan

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:

def f():
    x = yield 5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions