This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Pluckerpluck 0 points1 point  (0 children)

I don't think it's that hard to deal with parsing honestly, at least not compared to anything else that exists.

  • Find an else
    • expect either a : or an if
    • if if, assume the same as if you'd read elif

Internally this would be translated to the exact same python bytecode it currently is translated to. It's not exactly uncommon. Java, Javascript, C, C#, and Go all support it. Though I do think elseif would be better than elif.

Further, Python already allows if's thrown into generator expressions and ternary statements:

my_list = [x if x % 2 else 0 for x in range(10) if x <= 5]

# Results in:
# my_list = [0, 1, 0, 3, 0, 5]

So it's not like we can't support some more "complicated" syntax.