diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2020-03-06 05:19:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-06 05:19:22 (GMT) |
commit | 8bae21962bab2fac7630982abd73676b89930902 (patch) | |
tree | b720379ee0bb9aca6695fa04d4f6dc446f70d394 | |
parent | e63117a84ef11083be86db7afb2ac2789491ca09 (diff) | |
download | cpython-8bae21962bab2fac7630982abd73676b89930902.zip cpython-8bae21962bab2fac7630982abd73676b89930902.tar.gz cpython-8bae21962bab2fac7630982abd73676b89930902.tar.bz2 |
bpo-39868: Update Language Reference for PEP 572. (#18793)
-rw-r--r-- | Doc/reference/compound_stmts.rst | 6 | ||||
-rw-r--r-- | Doc/reference/expressions.rst | 18 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Documentation/2020-03-05-16-29-03.bpo-39868.JQoHhO.rst | 1 |
3 files changed, 19 insertions, 6 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index e2f44a5..ac2065b 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -90,8 +90,8 @@ The :keyword:`!if` statement The :keyword:`if` statement is used for conditional execution: .. productionlist:: - if_stmt: "if" `expression` ":" `suite` - : ("elif" `expression` ":" `suite`)* + if_stmt: "if" `assignment_expression` ":" `suite` + : ("elif" `assignment_expression` ":" `suite`)* : ["else" ":" `suite`] 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 expression is true: .. productionlist:: - while_stmt: "while" `expression` ":" `suite` + while_stmt: "while" `assignment_expression` ":" `suite` : ["else" ":" `suite`] This repeatedly tests the expression and, if it is true, executes the first diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index d9db33a..3fcc5e1 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -178,7 +178,7 @@ called "displays", each of them in two flavors: Common syntax elements for comprehensions are: .. productionlist:: - comprehension: `expression` `comp_for` + comprehension: `assignment_expression` `comp_for` comp_for: ["async"] "for" `target_list` "in" `or_test` [`comp_iter`] comp_iter: `comp_for` | `comp_if` comp_if: "if" `expression_nocond` [`comp_iter`] @@ -911,7 +911,8 @@ series of :term:`arguments <argument>`: : ["," `keywords_arguments`] : | `starred_and_keywords` ["," `keywords_arguments`] : | `keywords_arguments` - positional_arguments: ["*"] `expression` ("," ["*"] `expression`)* + positional_arguments: positional_item ("," positional_item)* + positional_item: `assignment_expression` | "*" `expression` starred_and_keywords: ("*" `expression` | `keyword_item`) : ("," "*" `expression` | "," `keyword_item`)* keywords_arguments: (`keyword_item` | "**" `expression`) @@ -1642,6 +1643,17 @@ returns a boolean value regardless of the type of its argument (for example, ``not 'foo'`` produces ``False`` rather than ``''``.) +Assignment expressions +====================== + +.. productionlist:: + assignment_expression: [`identifier` ":="] `expression` + +.. TODO: BPO-39868 + +See :pep:`572` for more details about assignment expressions. + + .. _if_expr: Conditional expressions @@ -1711,7 +1723,7 @@ Expression lists expression_list: `expression` ("," `expression`)* [","] starred_list: `starred_item` ("," `starred_item`)* [","] starred_expression: `expression` | (`starred_item` ",")* [`starred_item`] - starred_item: `expression` | "*" `or_expr` + starred_item: `assignment_expression` | "*" `or_expr` .. index:: object: tuple diff --git a/Misc/NEWS.d/next/Documentation/2020-03-05-16-29-03.bpo-39868.JQoHhO.rst b/Misc/NEWS.d/next/Documentation/2020-03-05-16-29-03.bpo-39868.JQoHhO.rst new file mode 100644 index 0000000..9fa8bfd --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2020-03-05-16-29-03.bpo-39868.JQoHhO.rst @@ -0,0 +1 @@ +Updated the Language Reference for :pep:`572`. |