Skip to content

Commit

Permalink
gh-86482: Document assignment expression need for ()s (GH-23291)
Browse files Browse the repository at this point in the history
Co-authored-by: Jelle Zijlstra <[email protected]>
(cherry picked from commit 2b5f136)

Co-authored-by: Terry Jan Reedy <[email protected]>
  • Loading branch information
miss-islington and terryjreedy authored Oct 6, 2022
1 parent 6057030 commit 4aa2ebc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,13 @@ Or, when processing a file stream in chunks:
while chunk := file.read(9000):
process(chunk)
Assignment expressions must be surrounded by parentheses when used
as sub-expressions in slicing, conditional, lambda,
keyword-argument, and comprehension-if expressions
and in ``assert`` and ``with`` statements.
In all other places where they can be used, parentheses are not required,
including in ``if`` and ``while`` statements.

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document some places where an assignment expression needs parentheses.

0 comments on commit 4aa2ebc

Please sign in to comment.