mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-86482: Document assignment expression need for ()s (#23291)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
6bfb0be804
commit
2b5f1360ea
2 changed files with 8 additions and 0 deletions
|
@ -1766,6 +1766,13 @@ 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.
|
||||
In all other places where they can be used, parentheses are not required,
|
||||
including in ``if`` and ``while`` statements.
|
||||
|
||||
.. versionadded:: 3.8
|
||||
See :pep:`572` for more details about assignment expressions.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue