Skip to content

Commit 8bae219

Browse files
authored
bpo-39868: Update Language Reference for PEP 572. (#18793)
1 parent e63117a commit 8bae219

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

Doc/reference/compound_stmts.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ The :keyword:`!if` statement
9090
The :keyword:`if` statement is used for conditional execution:
9191

9292
.. productionlist::
93-
if_stmt: "if" `expression` ":" `suite`
94-
: ("elif" `expression` ":" `suite`)*
93+
if_stmt: "if" `assignment_expression` ":" `suite`
94+
: ("elif" `assignment_expression` ":" `suite`)*
9595
: ["else" ":" `suite`]
9696

9797
It selects exactly one of the suites by evaluating the expressions one by one
@@ -116,7 +116,7 @@ The :keyword:`while` statement is used for repeated execution as long as an
116116
expression is true:
117117

118118
.. productionlist::
119-
while_stmt: "while" `expression` ":" `suite`
119+
while_stmt: "while" `assignment_expression` ":" `suite`
120120
: ["else" ":" `suite`]
121121

122122
This repeatedly tests the expression and, if it is true, executes the first

Doc/reference/expressions.rst

+15-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ called "displays", each of them in two flavors:
178178
Common syntax elements for comprehensions are:
179179

180180
.. productionlist::
181-
comprehension: `expression` `comp_for`
181+
comprehension: `assignment_expression` `comp_for`
182182
comp_for: ["async"] "for" `target_list` "in" `or_test` [`comp_iter`]
183183
comp_iter: `comp_for` | `comp_if`
184184
comp_if: "if" `expression_nocond` [`comp_iter`]
@@ -911,7 +911,8 @@ series of :term:`arguments <argument>`:
911911
: ["," `keywords_arguments`]
912912
: | `starred_and_keywords` ["," `keywords_arguments`]
913913
: | `keywords_arguments`
914-
positional_arguments: ["*"] `expression` ("," ["*"] `expression`)*
914+
positional_arguments: positional_item ("," positional_item)*
915+
positional_item: `assignment_expression` | "*" `expression`
915916
starred_and_keywords: ("*" `expression` | `keyword_item`)
916917
: ("," "*" `expression` | "," `keyword_item`)*
917918
keywords_arguments: (`keyword_item` | "**" `expression`)
@@ -1642,6 +1643,17 @@ returns a boolean value regardless of the type of its argument
16421643
(for example, ``not 'foo'`` produces ``False`` rather than ``''``.)
16431644

16441645

1646+
Assignment expressions
1647+
======================
1648+
1649+
.. productionlist::
1650+
assignment_expression: [`identifier` ":="] `expression`
1651+
1652+
.. TODO: BPO-39868
1653+
1654+
See :pep:`572` for more details about assignment expressions.
1655+
1656+
16451657
.. _if_expr:
16461658

16471659
Conditional expressions
@@ -1711,7 +1723,7 @@ Expression lists
17111723
expression_list: `expression` ("," `expression`)* [","]
17121724
starred_list: `starred_item` ("," `starred_item`)* [","]
17131725
starred_expression: `expression` | (`starred_item` ",")* [`starred_item`]
1714-
starred_item: `expression` | "*" `or_expr`
1726+
starred_item: `assignment_expression` | "*" `or_expr`
17151727

17161728
.. index:: object: tuple
17171729

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated the Language Reference for :pep:`572`.

0 commit comments

Comments
 (0)