[Python-ideas] "else if" as equivalent for "elif"

Ryan Gonzalez rymg19 at gmail.com
Sun Oct 25 19:03:12 EDT 2015


On Sat, Oct 24, 2015 at 3:39 AM, Sven R. Kunze <srkunze at mail.de> wrote:

> On 23.10.2015 18:09, Nick Coghlan wrote:
>
>> It's a big deal due to opportunity cost - any time that is spent on
>> making a second spelling of "elif" possible is time not spent working
>> on something that directly improves developer productivity (like
>> format strings) or application correctness (like gradual typing
>> support).
>>
>
> 1) I may re-iterate. Such thinking is dangerous. It could mean standstill.
> It prevents thinking and progress. That is python-ideas; not
> python-controlling.
>
> 2) Is Python not an open-source project? Could not anybody contribute? To
> me that means, the sky is the limit.
>
> 3) Well, that the features you mentioned really do what they promise can
> be only be proved if they are implemented and used. So, we will see how
> they fare. Same, btw., would be for "else if". All of your and mine great
> thoughts are just that: thoughts, assumptions, arguments. Not facts.
>
> Time spent on frivolous changes also (justifiably) annoys
>> users of the language given the large numbers of known problems we've
>> yet to figure out how to find the time and resources to resolve.
>>
>
> Cf. above.
>
> Okay, enough of resource-thinking. Back to topic.
>
>  From a learning perspective, remembering that "elif" is an
>> abbreviation of "else if" in Python isn't any more complicated than
>> remembering that "don't" is an abbreviation of "do not" in English.
>> It's certainly easier to remember than what "def" or "class" means.
>>
>
> Let's remember that.
>
>  From a readability perspective, inserting an "se " in the middle of
>> every elif clause doesn't really improve things:
>>
>>      if x == 1:
>>          ...
>>      elif x == 2:
>>          ...
>>      elif x == 3:
>>          ...
>>      else:
>>          ...
>>
>> vs:
>>
>>      if x == 1:
>>          ...
>>      else if x == 2:
>>          ...
>>      else if x == 3:
>>          ...
>>      else:
>>          ...
>>
>> It can actually be argued that it's *harder* to read, since the
>> typical English phrasing for this kind of formulation is more along
>> the lines of "X if case A, else Y if case B, else Z", which is the way
>> conditional expressions are written.
>>
>
> I thought "elif" is an abbreviation of "else if" as is "don't" to "do
> not". So, why are you arguing with differing semantics when it comes to
> readability?
>
> I for one think it improves things (as does several other people on the
> list), that is why it is on the list. ;-)
> Why you may ask? Because it just reads like an English sentence: "If that
> condition, then (==colon) do this, else if another condition, then
> (==colon) do that, etc. etc." So, we got "if", ":", and "else", this is
> just all we need to learn.
>
>
Two things:

1. That doesn't read like an English sentence. It sounds like an English
sentence spoken by someone who's been through a 48-hour C hackathon.
2. Well, elif is used almost everywhere, so 99% of the people who learn
Python will have to learn 'elif' the day after 'else if'.


>
> Something, I would be interested in is: what was the reason for
> introducing the non-English keyword "elif"? Parsing difficulties?
>
>
> Best,
> Sven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
Ryan
[ERROR]: Your autotools build scripts are 200 lines longer than your
program. Something’s wrong.
http://kirbyfan64.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151025/caced7b2/attachment-0001.html>


More information about the Python-ideas mailing list