8000 gh-115528: Update language reference for PEP 646 by mrahtz · Pull Request #121181 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-115528: Update language reference for PEP 646 #121181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify
  • Loading branch information
mrahtz committed Jun 30, 2024
commit e7c8c2540d822a0e2833495e7cbcd4aa817ebeba
26 changes: 13 additions & 13 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@
A list display is a possibly empty series of expressions enclosed in square
brackets:

.. productionlist:: python-grammar

Check warning on line 255 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:expression_list
list_display: "[" [`starred_list` | `comprehension`] "]"
list_display: "[" [`expression_list` | `comprehension`] "]"

A list display yields a new list object, the contents being specified by either
a list of expressions or a comprehension. When a comma-separated list of
Expand All @@ -277,8 +277,8 @@
A set display is denoted by curly braces and distinguishable from dictionary
displays by the lack of colons separating keys and values:

.. productionlist:: python-grammar

Check warning on line 280 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:expression_list
set_display: "{" (`starred_list` | `comprehension`) "}"
set_display: "{" (`expression_list` | `comprehension`) "}"

A set display yields a new mutable set object, the contents being specified by
either a sequence of expressions or a comprehension. When a comma-separated
Expand Down Expand Up @@ -420,7 +420,7 @@
pair: yield; expression
pair: generator; function

.. productionlist:: python-grammar

Check warning on line 423 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:yield_list
yield_atom: "(" `yield_expression` ")"
yield_from: "yield" "from" `expression`
yield_expression: "yield" `yield_list` | `yield_from`
Expand Down Expand Up @@ -450,13 +450,13 @@
functions are described separately in section
:ref:`asynchronous-generator-functions`.

When a generator function is called, it returns an iterator known as a

Check warning on line 453 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:expression_list

Check warning on line 453 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:expression_list
generator. That generator then controls the execution of the generator
function. The execution starts when one of the generator's methods is called.
At that time, the execution proceeds to the first yield expression, where it is
suspended again, returning the value of
:token:`~python-grammar:flexible_expression_list` to the generator's caller,
or ``None`` if :token:`~python-grammar:flexible_expression_list` is omitted.
:token:`~python-grammar:expression_list` to the generator's caller,
or ``None`` if :token:`~python-grammar:expression_list` is omitted.
By suspended, we mean that all local state is
retained, including the current bindings of local variables, the instruction
pointer, the internal evaluation stack, and the state of any exception handling.
Expand Down Expand Up @@ -540,12 +540,12 @@

.. method:: generator.__next__()

Starts the execution of a generator function or resumes it at the last

Check warning on line 543 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:expression_list
executed yield expression. When a generator function is resumed with a
:meth:`~generator.__next__` method, the current yield expression always
evaluates to :const:`None`. The execution then continues to the next yield
expression, where the generator is suspended again, and the value of the
:token:`~python-grammar:flexible_expression_list` is returned to
:token:`~python-grammar:expression_list` is returned to
:meth:`__next__`'s caller. If the generator exits without yielding another
value, a :exc:`StopIteration` exception is raised.

Expand Down Expand Up @@ -661,10 +661,10 @@
:keyword:`async for` statement in a coroutine function analogously to
how a generator object would be used in a :keyword:`for` statement.

Calling one of the asynchronous generator's methods returns an :term:`awaitable`

Check warning on line 664 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:expression_list
object, and the execution starts when this object is awaited on. At that time,
the execution proceeds to the first yield expression, where it is suspended
again, returning the value of :token:`~python-grammar:flexible_expression_list`
again, returning the value of :token:`~python-grammar:expression_list`
to the awaiting coroutine. As with a generator, suspension means that all local
state is retained, including the current bindings of local variables, the
instruction pointer, the internal evaluation stack, and the state of any
Expand Down D496 Expand Up @@ -723,12 +723,12 @@

.. coroutinemethod:: agen.__anext__()

Returns an awaitable which when run starts to execute the asynchronous

Check warning on line 726 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:expression_list
generator or resumes it at the last executed yield expression. When an
asynchronous generator function is resumed with an :meth:`~agen.__anext__`
method, the current yield expression always evaluates to :const:`None` in the
returned awaitable, which when run will continue to the next yield
expression. The value of the :token:`~python-grammar:flexible_expression_list`
expression. The value of the :token:`~python-grammar:expression_list`
of the yield expression is the value of the :exc:`StopIteration` exception
raised by the completing coroutine. If the asynchronous generator exits
without yielding another value, the awaitable instead raises a
Expand Down Expand Up @@ -861,7 +861,7 @@
:ref:`GenericAlias <types-genericalias>` object.

.. productionlist:: python-grammar
subscription: `primary` "[" `flexible_expression_list` "]"
subscription: `primary` "[" `expression_list` "]"

When an object is subscripted, the interpreter will evaluate the primary and
the expression list.
Expand Down Expand Up @@ -1879,11 +1879,11 @@

.. productionlist:: python-grammar

starred_item: "*" `or_expr`
flexible_expression: `expression` | `assignment_expression` | `starred_item`
flexible_expression_list: `flexible_expression` ("," `flexible_expression`)* [","]
yield_list: `expression` ["," `flexible_expression_list`]
| `starred_item` "," [`flexible_expression_list`]
expression_list: `flexible_expression` ("," `flexible_expression`)* [","]
yield_list: `expression` ["," `expression_list`]
| `starred_expression` "," [`expression_list`]
flexible_expression: `assignment_expression` | `starred_expression`
starred_expression: "*" `or_expr`

.. index:: pair: object; tuple

Expand Down
Loading
0