(original) (raw)
As anticippated, after a final round of feedback I am hereby accepting PEP 572, Assignment Expressions: https://www.python.org/dev/ peps/pep-0572/
Thanks to everyone who participated in the discussion or sent a PR.
Below is a list of changes since the last post (https://mail.python.org/ pipermail/python-dev/2018- July/154557.html) -- they are mostly cosmetic so I won't post the doc again, but if you want to go over them in detail, here's the history of the file on GitHub: https://github.com/python/ peps/commits/master/pep-0572. rst, and here's a diff since the last posting: https://github.com/python/ peps/compare/26e6f61f...master (sadly it's repo-wide -- you can click on Files changed and then navigate to pep-0572.rst).
- Tweaked the example at line 95-100 to use
result = ...
rather thanreturn ...
so as to make a different rewrite less feasible - Replaced the weak "2-arg iter" example with Giampaolo Roloda's
while chunk := file.read(8192): process(chunk)
- Added prohibition of unparenthesized assignment expressions in annotations and lambdas
- Clarified that
TargetScopeError
is a new subclass ofSyntaxError
- Clarified the text forbidding assignment to comprehension loop control variables
- Clarified that the prohibition on
:=
with annotation applies to inline annotation (i.e. they cannot be syntactically combined in the same expression) - Added conditional expressions to the things
:=
binds less tightly than - Dropped section "This could be used to create ugly code"
- Clarified the example in Appendix C