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

*...else...else dedentation #56

Open
kbrose opened this issue Nov 19, 2019 · 0 comments
Open

*...else...else dedentation #56

kbrose opened this issue Nov 19, 2019 · 0 comments

Comments

@kbrose
Copy link
Owner

kbrose commented Nov 19, 2019

Minimal code example:

What the code looks like before pressing enter:

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
        else:|

What I want the code to look like after pressing enter:

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
else:|

What the code actually looks like after pressing enter:

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
    else:|

Also, starting from

if True:
    for i in range(5):
        print(i)
    else:
        print('no break!')
    else:|

should end up with the desired behavior shown above too.

Typically, I don't dedent past the point where the else/elif/except/finally keyword could be placed and still be syntactically correct, but in cases like these where we've already "consumed" the for's (or while's or try's) else, we know that the final else must be meant for the if.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant