8000 [3.12] gh-111944: Add assignment expression parentheses requirements … · python/cpython@3b7e308 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b7e308

Browse files
[3.12] gh-111944: Add assignment expression parentheses requirements (GH-111977) (#112010)
Augment the list of places where parentheses are required around assignnment statements. In particular, 'a := 0' and 'a = b := 1' are syntax errors. (cherry picked from commit 9a2f25d) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent 378a96e commit 3b7e308

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/reference/expressions.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,10 +1774,11 @@ Or, when processing a file stream in chunks:
17741774
while chunk := file.read(9000):
17751775
process(chunk)
17761776
1777-
Assignment expressions must be surrounded by parentheses when used
1778-
as sub-expressions in slicing, conditional, lambda,
1779-
keyword-argument, and comprehension-if expressions
1780-
and in ``assert`` and ``with`` statements.
1777+
Assignment expressions must be surrounded by parentheses when
1778+
used as expression statements and when used as sub-expressions in
1779+
slicing, conditional, lambda,
1780+
keyword-argument, and comprehension-if expressions and
1781+
in ``assert``, ``with``, and ``assignment`` statements.
17811782
In all other places where they can be used, parentheses are not required,
17821783
including in ``if`` and ``while`` statements.
17831784

0 commit comments

Comments
 (0)
0