Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb7487df

Browse files
gh-86482: Document assignment expression need for ()s (GH-23291)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>(cherry picked from commit2b5f136)Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent3d89ac2 commitb7487df

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

‎Doc/reference/expressions.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,13 @@ Or, when processing a file stream in chunks:
17481748
while chunk:=file.read(9000):
17491749
process(chunk)
17501750
1751+
Assignment expressions must be surrounded by parentheses when used
1752+
as sub-expressions in slicing, conditional, lambda,
1753+
keyword-argument, and comprehension-if expressions
1754+
and in ``assert`` and ``with`` statements.
1755+
In all other places where they can be used, parentheses are not required,
1756+
including in ``if`` and ``while`` statements.
1757+
17511758
..versionadded::3.8
17521759
See:pep:`572` for more details about assignment expressions.
17531760

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document some places where an assignment expression needs parentheses.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp