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 with "elif" #8115

Closed
wants to merge 1 commit into from
Closed

WIP: Use assign expr with "elif" #8115

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jul 5, 2018

Replace:

else:
    var = expr
    if var:
        ...

with:

elif (var := expr):
    ...

Replace:

    else:
        var = expr
        if var:
            ...

with:

    elif (var := expr):
        ...
@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

@vstinner
Copy link
Member Author

vstinner commented Jul 5, 2018

See also PR #8097 which is similar but specific to match/group.

@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 deleted the wip_elif_assign_expr 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.

None yet

3 participants