Skip to content

WIP: Use assign expr in list comprehension#8098

Closed
vstinner wants to merge 1 commit into
python:masterfrom
vstinner:wip_assign_expr_list_comp
Closed

WIP: Use assign expr in list comprehension#8098
vstinner wants to merge 1 commit into
python:masterfrom
vstinner:wip_assign_expr_list_comp

Conversation

@vstinner

@vstinner vstinner commented Jul 5, 2018

Copy link
Copy Markdown
Member

Modify for loops and list comprehensions to use assignment
expressions.

Modify for loops and list comprehensions to use assignment
expressions.
@vstinner

vstinner commented Jul 5, 2018

Copy link
Copy Markdown
Member Author

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

Comment thread Lib/mailbox.py
if label.strip()]
labels = [slabel for label
in self._file.readline()[1:].split(b',')
if (slabel := label.strip())]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

@vstinner

Copy link
Copy Markdown
Member Author

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.

@vstinner vstinner closed this Jul 12, 2018
@vstinner vstinner deleted the wip_assign_expr_list_comp branch July 12, 2018 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants