gh-86482: Document assignment expression need for ()s (GH-23291)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 2b5f1360ea)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Miss Islington (bot) 2022-10-06 12:32:39 -07:00 committed by Pablo Galindo
parent a3df8d7141
commit cc10a8e81c
No known key found for this signature in database
GPG Key ID: FFE87404168BD847
2 changed files with 8 additions and 0 deletions

View File

@ -1751,6 +1751,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.

View File

@ -0,0 +1 @@
Document some places where an assignment expression needs parentheses.