diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2023-11-13 00:06:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 00:06:50 (GMT) |
commit | 9a2f25d374f027f6509484d66e1c7bba03977b99 (patch) | |
tree | ac7f695de18de8249379e8630bbba261b3ea2507 /Doc | |
parent | d7cef7bc7ea5478abb90a37c8ffb0792cc6e7518 (diff) | |
download | cpython-9a2f25d374f027f6509484d66e1c7bba03977b99.zip cpython-9a2f25d374f027f6509484d66e1c7bba03977b99.tar.gz cpython-9a2f25d374f027f6509484d66e1c7bba03977b99.tar.bz2 |
gh-111944: Add assignment expression parentheses requirements (#111977)
gh-111944: Clarify where assignment expressions require ()s
Augment the list of places where parentheses are
required around assignnment statements. In particular,
'a := 0' and 'a = b := 1' are syntax errors.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/reference/expressions.rst | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 88d4fca..14c2afa 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1781,10 +1781,11 @@ 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. +Assignment expressions must be surrounded by parentheses when +used as expression statements and when used as sub-expressions in +slicing, conditional, lambda, +keyword-argument, and comprehension-if expressions and +in ``assert``, ``with``, and ``assignment`` statements. In all other places where they can be used, parentheses are not required, including in ``if`` and ``while`` statements. |