mirror of https://github.com/python/cpython.git
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:
parent
a3df8d7141
commit
cc10a8e81c
|
@ -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.
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Document some places where an assignment expression needs parentheses.
|
Loading…
Reference in New Issue