Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a2f25d

Browse filesBrowse files
authored
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.
1 parent d7cef7b commit 9a2f25d
Copy full SHA for 9a2f25d

File tree

1 file changed

+5
-4
lines changed
Filter options

1 file changed

+5
-4
lines changed

‎Doc/reference/expressions.rst

Copy file name to clipboardExpand all lines: Doc/reference/expressions.rst
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,10 +1781,11 @@ Or, when processing a file stream in chunks:
17811781
while chunk := file.read(9000):
17821782
process(chunk)
17831783
1784-
Assignment expressions must be surrounded by parentheses when used
1785-
as sub-expressions in slicing, conditional, lambda,
1786-
keyword-argument, and comprehension-if expressions
1787-
and in ``assert`` and ``with`` statements.
1784+
Assignment expressions must be surrounded by parentheses when
1785+
used as expression statements and when used as sub-expressions in
1786+
slicing, conditional, lambda,
1787+
keyword-argument, and comprehension-if expressions and
1788+
in ``assert``, ``with``, and ``assignment`` statements.
17881789
In all other places where they can be used, parentheses are not required,
17891790
including in ``if`` and ``while`` statements.
17901791

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.