[Python-ideas] "else if" as equivalent for "elif"
Andrew Barnert
abarnert at yahoo.com
Wed Oct 21 21:10:03 CEST 2015
On Oct 21, 2015, at 11:16, Sven R. Kunze <srkunze at mail.de> wrote:
>
>> On 21.10.2015 20:05, Ryan Gonzalez wrote:
>> The Python Zen says:
>>
>> There should be one-- and preferably only one --obvious way to do it.
>>
>> elif uses less typing, anyway. Why type 3 more characters when you really don't need to? :D
>
> Because it's one of those "Python looks strange"? ;-)
Unless you also deprecate "elif", Python will still look strange—it'll just look inconsistently strange, which is even worse than consistently strange.
Besides, it's not as if "else if" reads like English any more than "elif" does. In English, you'd use a semicolon and an "if" for all but the last, and "or if" for the last (or, if there's only one, maybe "otherwise if" or "but if", depending on the connotations).
Also, the number of people coming to Python from C and its descendants (especially Java and JavaScript) is high enough that the false impression given by "else if" (that it's just an if statement controlled by an else clause) could be harmful. Yes, once you think about it, the fact that there's no colon after the "else" and only one level of indentation instead of two makes sense, but you shouldn't have to think about it.
More information about the Python-ideas
mailing list