Case Statements

Antoon Pardon antoon.pardon at rece.vub.ac.be
Wed Mar 16 06:52:13 EDT 2016


Op 16-03-16 om 10:51 schreef Mark Lawrence:
> On 16/03/2016 09:35, Antoon Pardon wrote:
>> Op 16-03-16 om 09:47 schreef Mark Lawrence:
>>>
>>>>
>>>> Same with switch. You can use a hash table etc. to simulate switches,
>>>> but only if the codeblocks are independent. Otherwise, if-elif chains
>>>> are the way to go. Command line parsing is a case where switch
>>>> statements are often used, e.g. in shell scripts.
>>>
>>> I've seen at least six different ways of simulating switches, so those
>>> people who want them, can have them.  if-elif chains are not likely to
>>> kill any Python programmer.
>>>
>>> I have no interest what other languages use switch/case statements
>>> for, as we've on the PYTHON mailing list.
>>
>> There once were multiple ways to simulate a conditional expression.
>> And it was generally thought that using if else statements instead
>> of a conditional expression was unlikely to kill any Python programmer.
>>
>> But then one of the core developers was bitten by a nasty bug because
>> he was using one of those constructs that simulated a conditional
>> expression and soon enough Python had a conditional expression.
>>
>> So I guess those who would like a case statement in Python can
>> only hope a core developer gets bitten by a nasty bug while using
>> one of those ways of simulating switches.
>>
>
> So that core developers can waste their time putting something into
> the language that we've done without for 25 years, yes, that strikes
> me as extremely worthwhile.

Do you think python should stop progressing? Because all progress
python wil make, will be done by putting something in the language
we've done without for 25 years.

That we have done without doesn't contradict it can be useful to have.

-- 
Antoon.




More information about the Python-list mailing list