Skip to content

WIP: Use assign expr with "elif"#8115

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

WIP: Use assign expr with "elif"#8115
vstinner wants to merge 1 commit into
python:masterfrom
vstinner:wip_elif_assign_expr

Conversation

@vstinner

@vstinner vstinner commented Jul 5, 2018

Copy link
Copy Markdown
Member

Replace:

else:
    var = expr
    if var:
        ...

with:

elif (var := expr):
    ...

Replace:

    else:
        var = expr
        if var:
            ...

with:

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

@vstinner

vstinner commented Jul 5, 2018

Copy link
Copy Markdown
Member Author

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

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

3 participants