8000 gh-86482: Document assignment expression need for ()s by terryjreedy · Pull Request #23291 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-86482: Document assignment expression need for ()s #23291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-42316: Document assignment expression need for ()s
The list should cover most places where an assignment sub-expression
must be wrapped in parentheses. Judging from the statement docs,
only a couple of statements do not require that they be wrapped.
  • Loading branch information
terryjreedy committed Nov 15, 2020
commit ff66b334abf488a56f75ad59f1dc48787d2f624d
5 changes: 5 additions & 0 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,11 @@ Or, when processing a file stream in chunks:
while chunk := file.read(9000):
process(chunk)

Assignment expressions must surrounded by parentheses when used
as sub-expressions in subscript, slicing, conditional, lambda,
keyword-argument, generator, and comprehension-if expressions. They
can only be used as is in if and while statements and in decorators.

.. versionadded:: 3.8
See :pep:`572` for more details about assignment expressions.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document some places where an assignment expression needs parentheses.
0