bpo-39868: Update Language Reference for PEP 572. (#18793)

This commit is contained in:
Brandt Bucher 2020-03-05 21:19:22 -08:00 committed by GitHub
parent e63117a84e
commit 8bae21962b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1 @@
Updated the Language Reference for :pep:`572`.