There was an error while loading. Please reload this page.
1 parent 6057030 commit 4aa2ebcCopy full SHA for 4aa2ebc
2 files changed
Doc/reference/expressions.rst
@@ -1755,6 +1755,13 @@ Or, when processing a file stream in chunks:
1755
while chunk := file.read(9000):
1756
process(chunk)
1757
1758
+Assignment expressions must be surrounded by parentheses when used
1759
+as sub-expressions in slicing, conditional, lambda,
1760
+keyword-argument, and comprehension-if expressions
1761
+and in ``assert`` and ``with`` statements.
1762
+In all other places where they can be used, parentheses are not required,
1763
+including in ``if`` and ``while`` statements.
1764
+
1765
.. versionadded:: 3.8
1766
See :pep:`572` for more details about assignment expressions.
1767
Misc/NEWS.d/next/Core and Builtins/2020-11-15-02-08-43.bpo-42316.LqdkWK.rst
@@ -0,0 +1 @@
1
+Document some places where an assignment expression needs parentheses.
0 commit comments