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

Activity

  1. StanFromIreland commented on Sep 2, 2026

    @StanFromIreland
    Member
  2. dluschan commented on Sep 2, 2026

    @dluschan
    Author

    There is a similar issue with the use of the term “statement” below, in section 3.2.8.5 (“Asynchronous generator functions”).

  3. lul-cas commented on Sep 2, 2026

    @lul-cas
    SponsorContributor

    Hi!
    Opened a PR for this.

  4. added 3 commits that reference this issue on Sep 9, 2026
  5. added a commit that references this issue on Sep 11, 2026
  6. added a commit that references this issue on Sep 12, 2026
  7. added a commit that references this issue on Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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