From 9516cd47daaf468a279f25dc1f6a837bed75cd62 Mon Sep 17 00:00:00 2001 From: Alexander Ershov Date: Wed, 15 Apr 2026 10:58:01 +0700 Subject: [PATCH] Correct inaccuracies in syntax documentation --- Doc/reference/expressions.rst | 4 ++-- Doc/reference/simple_stmts.rst | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 68dcfc00bbd99c..d2e24f324105d3 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -321,7 +321,7 @@ Parenthesized forms A parenthesized form is an optional expression list enclosed in parentheses: .. productionlist:: python-grammar - parenth_form: "(" [`starred_expression`] ")" + parenth_form: "(" [`flexible_expression_list`] ")" A parenthesized expression list yields whatever that expression list yields: if the list contains at least one comma, it yields a tuple; otherwise, it yields @@ -628,7 +628,7 @@ Yield expressions .. productionlist:: python-grammar yield_atom: "(" `yield_expression` ")" yield_from: "yield" "from" `expression` - yield_expression: "yield" `yield_list` | `yield_from` + yield_expression: "yield" [`yield_list` | `yield_from`] The yield expression is used when defining a :term:`generator` function or an :term:`asynchronous generator` function and diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index 9b84c2e9ac7017..82aa1ae3bffbb1 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -48,7 +48,7 @@ expression statements are allowed and occasionally useful. The syntax for an expression statement is: .. productionlist:: python-grammar - expression_stmt: `starred_expression` + expression_stmt: `starred_expression_list` An expression statement evaluates the expression list (which may be a single expression). @@ -84,7 +84,7 @@ Assignment statements are used to (re)bind names to values and to modify attributes or items of mutable objects: .. productionlist:: python-grammar - assignment_stmt: (`target_list` "=")+ (`starred_expression` | `yield_expression`) + assignment_stmt: (`target_list` "=")+ (`starred_expression_list` | `yield_expression`) target_list: `target` ("," `target`)* [","] target: `identifier` : | "(" [`target_list`] ")" @@ -275,7 +275,7 @@ Augmented assignment is the combination, in a single statement, of a binary operation and an assignment statement: .. productionlist:: python-grammar - augmented_assignment_stmt: `augtarget` `augop` (`expression_list` | `yield_expression`) + augmented_assignment_stmt: `augtarget` `augop` (`starred_expression_list` | `yield_expression`) augtarget: `identifier` | `attributeref` | `subscription` augop: "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**=" : | ">>=" | "<<=" | "&=" | "^=" | "|=" @@ -324,7 +324,7 @@ statement, of a variable or attribute annotation and an optional assignment stat .. productionlist:: python-grammar annotated_assignment_stmt: `augtarget` ":" `expression` - : ["=" (`starred_expression` | `yield_expression`)] + : ["=" (`starred_expression_list` | `yield_expression`)] The difference from normal :ref:`assignment` is that only a single target is allowed.