Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add PEP 572 grammar docs to the Language Reference.
  • Loading branch information
brandtbucher committed Mar 6, 2020
commit ecddd10a47b61fe1a5768638fea29e5eac6db5cb
6 changes: 3 additions & 3 deletions Doc/reference/compound_stmts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think "expression" here needs updating too? It becomes a bit ugly that way, and in context it doesn't seem ambiguous.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I thought more about it and I don't think it needs updating, so I'll land now.)

Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,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: `conditional_expression` [":=" `conditional_expression`]

.. XXX TODO!

See :pep:`572` for more details about assignment expressions.


.. _if_expr:

Conditional expressions
Expand Down