Skip to content
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

WIP: Use assign expr in list comprehension #8098

Closed
wants to merge 1 commit into from
Closed

WIP: Use assign expr in list comprehension #8098

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jul 5, 2018

Modify for loops and list comprehensions to use assignment
expressions.

Modify for loops and list comprehensions to use assignment
expressions.
@vstinner
Copy link
Member Author

vstinner commented Jul 5, 2018

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())]

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