From 6873af503a42a935cb49ce2f39a5c77afec1fb6f Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 12:15:10 +0530 Subject: [PATCH 01/22] doc: clarify for_stmt grammar by replacing starred_list with expression_list --- Doc/reference/compound_stmts.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 5d4298f70e0e14..76f1c31a3ebf66 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -151,21 +151,22 @@ The :keyword:`!for` statement single: : (colon); compound statement 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: +(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" `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 suite in the :keyword:`!else` clause, +The ``expression_list`` 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. +Note that as of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported +in the iterable expression list. + .. index:: pair: statement; break pair: statement; continue From 37950655116f69a7bf06cf61063e5e121652348e Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 13:03:03 +0530 Subject: [PATCH 02/22] star_expressions --- Doc/reference/compound_stmts.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 76f1c31a3ebf66..1c2fbe015bf3bb 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -154,18 +154,18 @@ 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" `expression_list` ":" `suite` + for_stmt: "for" `target_list` "in" `star_expressions` ":" `suite` : ["else" ":" `suite`] -The ``expression_list`` is evaluated once; it should yield an :term:`iterable` object. +The expression following ``in`` 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. -Note that as of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported -in the iterable expression list. +As of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported +in the iterable expression. This follows the same rules as :token:`star_expressions` in the grammar. .. index:: pair: statement; break From 1152b1bd6ca3da5dfbf1b33779a510ebdfac55ae Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 14:26:06 +0530 Subject: [PATCH 03/22] star_expressions --- Doc/reference/compound_stmts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 1c2fbe015bf3bb..dee4e5b2d492e4 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -154,7 +154,7 @@ 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" `star_expressions` ":" `suite` + for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] The expression following ``in`` is evaluated once; it should yield an :term:`iterable` object. @@ -165,7 +165,7 @@ by the iterator. When the iterator is exhausted, the suite in the :keyword:`!els if present, is executed, and the loop terminates. As of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported -in the iterable expression. This follows the same rules as :token:`star_expressions` in the grammar. +in the iterable expression. This follows the same rules as :token:`starred_expression_list` in the grammar. .. index:: pair: statement; break From 9967ec9e9e42370bd3ced0a3e93167ce831401ec Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 14:38:48 +0530 Subject: [PATCH 04/22] star_expressions --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index dee4e5b2d492e4..2c0b4baf599abf 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -165,7 +165,7 @@ by the iterator. When the iterator is exhausted, the suite in the :keyword:`!els if present, is executed, and the loop terminates. As of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported -in the iterable expression. This follows the same rules as :token:`starred_expression_list` in the grammar. +in the iterable expression. .. index:: pair: statement; break From 9442bf8a02af706934805ec0c676867ae872142a Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 12:15:10 +0530 Subject: [PATCH 05/22] doc: clarify for_stmt grammar by replacing starred_list with expression_list --- Doc/reference/compound_stmts.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 5d4298f70e0e14..76f1c31a3ebf66 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -151,21 +151,22 @@ The :keyword:`!for` statement single: : (colon); compound statement 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: +(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" `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 suite in the :keyword:`!else` clause, +The ``expression_list`` 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. +Note that as of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported +in the iterable expression list. + .. index:: pair: statement; break pair: statement; continue From c9abb45723e0b59cad8987bf5b14c842a814b460 Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 13:03:03 +0530 Subject: [PATCH 06/22] star_expressions --- Doc/reference/compound_stmts.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 76f1c31a3ebf66..1c2fbe015bf3bb 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -154,18 +154,18 @@ 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" `expression_list` ":" `suite` + for_stmt: "for" `target_list` "in" `star_expressions` ":" `suite` : ["else" ":" `suite`] -The ``expression_list`` is evaluated once; it should yield an :term:`iterable` object. +The expression following ``in`` 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. -Note that as of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported -in the iterable expression list. +As of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported +in the iterable expression. This follows the same rules as :token:`star_expressions` in the grammar. .. index:: pair: statement; break From ec6005b4e7e6010fd0c6992eaada0a9d1f81c301 Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 14:26:06 +0530 Subject: [PATCH 07/22] star_expressions --- Doc/reference/compound_stmts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 1c2fbe015bf3bb..dee4e5b2d492e4 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -154,7 +154,7 @@ 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" `star_expressions` ":" `suite` + for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] The expression following ``in`` is evaluated once; it should yield an :term:`iterable` object. @@ -165,7 +165,7 @@ by the iterator. When the iterator is exhausted, the suite in the :keyword:`!els if present, is executed, and the loop terminates. As of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported -in the iterable expression. This follows the same rules as :token:`star_expressions` in the grammar. +in the iterable expression. This follows the same rules as :token:`starred_expression_list` in the grammar. .. index:: pair: statement; break From e760500101137f618e35faac168c76f403aa8903 Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Thu, 15 May 2025 14:38:48 +0530 Subject: [PATCH 08/22] star_expressions --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index dee4e5b2d492e4..2c0b4baf599abf 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -165,7 +165,7 @@ by the iterator. When the iterator is exhausted, the suite in the :keyword:`!els if present, is executed, and the loop terminates. As of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported -in the iterable expression. This follows the same rules as :token:`starred_expression_list` in the grammar. +in the iterable expression. .. index:: pair: statement; break From b8beb7d1a32625e0a5d5f37df78b32aa0207b87d Mon Sep 17 00:00:00 2001 From: Yash-Vijay29 Date: Fri, 16 May 2025 09:51:46 +0530 Subject: [PATCH 09/22] star_expressions --- Doc/reference/compound_stmts.rst | 22 +++++++++++----------- Doc/reference/expressions.rst | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 2c0b4baf599abf..8fc766dea10e89 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,15 +157,14 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The expression following ``in`` 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. - -As of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported -in the iterable expression. +The expression following ``in`` 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:: pair: statement; break @@ -197,7 +196,7 @@ the built-in type :func:`range` represents immutable arithmetic sequences of int For instance, iterating ``range(3)`` successively yields 0, 1, and then 2. .. versionchanged:: 3.11 - Starred elements are now allowed in the expression list. + starred elements are now allowed in the expression list. .. _try: @@ -234,7 +233,8 @@ and information on using the :keyword:`raise` statement to generate exceptions may be found in section :ref:`raise`. .. versionchanged:: 3.14 - Support for optionally dropping grouping parentheses when using multiple exception types. See :pep:`758`. + Support for optionally dropping grouping parentheses when using multiple + exception types. See :pep:`758`. .. _except: diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 8837344e5ddca1..2a550b504ca765 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -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`)* [","] From e908fce133821fe48ef11a4ad97e49df14a981d1 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Fri, 16 May 2025 09:58:46 +0530 Subject: [PATCH 10/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 8fc766dea10e89..cd5a59d0f18b28 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -163,8 +163,7 @@ 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. +executed, and the loop terminates. .. index:: pair: statement; break From 50f1e099e9cb622ee0f68f66a4df3302bf4859d4 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Fri, 16 May 2025 10:01:18 +0530 Subject: [PATCH 11/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index cd5a59d0f18b28..074c304ec31fae 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -195,7 +195,7 @@ the built-in type :func:`range` represents immutable arithmetic sequences of int For instance, iterating ``range(3)`` successively yields 0, 1, and then 2. .. versionchanged:: 3.11 - starred elements are now allowed in the expression list. + Starred elements are now allowed in the expression list. .. _try: From 8e860fa370046bbcdc1e46440ceda94446f70781 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Fri, 16 May 2025 19:13:09 +0530 Subject: [PATCH 12/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 074c304ec31fae..34fed37a5931ab 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,13 +157,14 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The expression following ``in`` 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. +The ``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:: pair: statement; break From 0866ba28353c99227f62dc29b65fcc5b46ef7bb6 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Fri, 16 May 2025 19:15:22 +0530 Subject: [PATCH 13/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 34fed37a5931ab..a55ab53c511a8a 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -233,8 +233,7 @@ and information on using the :keyword:`raise` statement to generate exceptions may be found in section :ref:`raise`. .. versionchanged:: 3.14 - Support for optionally dropping grouping parentheses when using multiple - exception types. See :pep:`758`. + Support for optionally dropping grouping parentheses when using multiple exception types. See :pep:`758`. .. _except: From 27c94a6f8c6aefa77363bea9658cad5b04977c7a Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Fri, 16 May 2025 20:20:01 +0530 Subject: [PATCH 14/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index a55ab53c511a8a..c6a323d829af87 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -151,7 +151,7 @@ The :keyword:`!for` statement single: : (colon); compound statement 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: +(such as a string, tuple or list) or other iterable object: .. productionlist:: python-grammar for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` From 99c40ff81e1102ddb7dd0cee5491d20d0e0e7152 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Sun, 18 May 2025 11:37:59 +0530 Subject: [PATCH 15/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index c6a323d829af87..10c1321581c2a6 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,8 +157,8 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The ``starred_expression_list`` expression is evaluated once; it should yield an -:term:`iterable` object. An :term:`iterator` is created for that iterable. +The :token:`~python-grammar:star_expressions` 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 From a4485481bd25cf1dc357a2b5ea7d46eb4aefde8a Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Sun, 18 May 2025 11:44:30 +0530 Subject: [PATCH 16/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 10c1321581c2a6..508f246c35eb0c 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,7 +157,7 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The :token:`~python-grammar:star_expressions` expression is evaluated once; it should +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 From cab198f98e6a53c97fc9fd860bffaf01af0a12fb Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Sun, 18 May 2025 13:13:15 +0530 Subject: [PATCH 17/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 508f246c35eb0c..25a53d45eab3cc 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,7 +157,7 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The :token:`~python-grammar:starred_expression_list` expression is evaluated once; it should +The `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 From 5b1fad3ae9ec62af1ee0c14e1dea497e65720e4f Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Sun, 18 May 2025 13:15:57 +0530 Subject: [PATCH 18/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 25a53d45eab3cc..776106514feec8 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,7 +157,7 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The `starred_expression_list` expression is evaluated once; it should +The ``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 From a4839cb82f2ef57092a71c12434171b880c20c0e Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Sun, 18 May 2025 13:24:53 +0530 Subject: [PATCH 19/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 776106514feec8..221df0241fb919 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,10 +157,9 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The ``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 +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, From 9af4d49b5f7ca5c435137650e06f60ce2fd27590 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Sun, 18 May 2025 14:31:53 +0530 Subject: [PATCH 20/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 221df0241fb919..65158b7a20496c 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,7 +157,7 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -The :token:`~python-grammar:starred_expression_list` expression is evaluated once; +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 From 5ce932e00253701ab4e0f6665a9faf752ed71719 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Wed, 21 May 2025 18:16:20 +0530 Subject: [PATCH 21/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 65158b7a20496c..2f8bd631b9bf50 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,11 +157,12 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -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 :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. From 04172617be6b900deebbccac14d2834f69dbe2a7 Mon Sep 17 00:00:00 2001 From: Yash Vijay Date: Wed, 21 May 2025 18:44:40 +0530 Subject: [PATCH 22/22] Update compound_stmts.rst --- Doc/reference/compound_stmts.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 2f8bd631b9bf50..e95fa3a6424e23 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -157,11 +157,11 @@ The :keyword:`for` statement is used to iterate over the elements of a sequence for_stmt: "for" `target_list` "in" `starred_expression_list` ":" `suite` : ["else" ":" `suite`] -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 +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. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy