diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-10-06 19:33:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-06 19:33:23 (GMT) |
commit | b7487dff302767bd2aed92df04d440f15c2eca14 (patch) | |
tree | c3e0dace99ddfe7e6159efa3f327c1460e9b17c0 /Doc | |
parent | 3d89ac2f4c573f5facde11579db0791832f5b392 (diff) | |
download | cpython-b7487dff302767bd2aed92df04d440f15c2eca14.zip cpython-b7487dff302767bd2aed92df04d440f15c2eca14.tar.gz cpython-b7487dff302767bd2aed92df04d440f15c2eca14.tar.bz2 |
gh-86482: Document assignment expression need for ()s (GH-23291)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 2b5f1360ead9aa72ae00de59edfd6c229d13933f)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/reference/expressions.rst | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 0a9e714..1e76b25 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1748,6 +1748,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. |