]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-134026: Fix grammar description of for statement (GH-134034)
authorYash Vijay <yash_vijay@outlook.com>
Wed, 21 May 2025 14:09:28 +0000 (19:39 +0530)
committerGitHub <noreply@github.com>
Wed, 21 May 2025 14:09:28 +0000 (16:09 +0200)
Doc/reference/compound_stmts.rst
Doc/reference/expressions.rst

index 5d4298f70e0e14540a51b593f8442e882ccec30a..e95fa3a6424e23e1a8bb8a84f2193d4b76b2daa4 100644 (file)
@@ -154,15 +154,15 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence
 (such as a string, tuple or list) or other iterable object:
 
 .. productionlist:: python-grammar
-   for_stmt: "for" `target_list` "in" `starred_list` ":" `suite`
+   for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite`
            : ["else" ":" `suite`]
 
-The ``starred_list`` expression is evaluated once; it should yield an
-:term:`iterable` object.  An :term:`iterator` is created for that iterable.
-The first item provided
-by the iterator is then assigned to the target list using the standard
-rules for assignments (see :ref:`assignment`), and the suite is executed.  This
-repeats for each item provided by the iterator.  When the iterator is exhausted,
+The :token:`~python-grammar:starred_expression_list` expression is evaluated
+once; it should yield an :term:`iterable` object. An :term:`iterator` is
+created for that iterable. The first item provided by the iterator is then
+assigned to the target list using the standard rules for assignments
+(see :ref:`assignment`), and the suite is executed. This repeats for each
+item provided by the iterator. When the iterator is exhausted,
 the suite in the :keyword:`!else` clause,
 if present, is executed, and the loop terminates.
 
index 8837344e5ddca1a81936acae155eabbdf479a55e..2a550b504ca7652c0ace08a53569e9bc4615cb60 100644 (file)
@@ -1928,7 +1928,7 @@ Expression lists
    single: , (comma); expression list
 
 .. productionlist:: python-grammar
-   starred_expression: ["*"] `or_expr`
+   starred_expression: "*" `or_expr` | `expression`
    flexible_expression: `assignment_expression` | `starred_expression`
    flexible_expression_list: `flexible_expression` ("," `flexible_expression`)* [","]
    starred_expression_list: `starred_expression` ("," `starred_expression`)* [","]