Skip to content

Commit

Permalink
pythongh-86482: Document assignment expression need for ()s (python#2…
Browse files Browse the repository at this point in the history
…3291)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
  • Loading branch information
terryjreedy and JelleZijlstra committed Oct 6, 2022
1 parent 6bfb0be commit 2b5f136
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
Expand Up @@ -1766,6 +1766,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
@@ -0,0 +1 @@
Document some places where an assignment expression needs parentheses.

0 comments on commit 2b5f136

Please sign in to comment.