WIP: Use assign expr in list comprehension#8098
Conversation
Modify for loops and list comprehensions to use assignment expressions.
|
As my previous PR #8095, I didn't write this PR to merge it, but just to discuss when it's appropriate or not to use assingment expressions (PEP 572). That's why I wrote "WIP" in the title and added the DO-NOT-MERGE label. Discussion: https://mail.python.org/pipermail/python-dev/2018-July/154323.html |
| if label.strip()] | ||
| labels = [slabel for label | ||
| in self._file.readline()[1:].split(b',') | ||
| if (slabel := label.strip())] |
There was a problem hiding this comment.
This is a counter-example to the "real programmers won't repeat stuff stuff today; they'll just move it to another line, which isn't that hard." (That said, I hope label.strip() is a relatively cheap operation, and that the second invocation will end up re-using the same location, so there won't be much memory churn.)
|
The PEP 572 has been accepted. I only wrote these WIP PEPs to help me to discuss the PEP. I never intended to propose these changes to be merged. So I close this PR. |
Modify for loops and list comprehensions to use assignment
expressions.