Case Statements

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Mar 16 00:26:02 EDT 2016


On 16/03/2016 01:55, jj0gen0info at gmail.com wrote:
> You have apparently mistaken me for someone who's worried.  I don't use Python, I was just curious as to why a construct that is found, not only to be useful in 95% of other languages, but is generally considered more flexible and readable than the if-elif, was missing in Python.  (your link "Switch Statement Code Smell" not withstanding)
>
> Have a great day :)
>

So you would rather write something like:-

switch (x):
   case COW:
     moo()
     break

   case DUCK:
     quack()
     break

   default IDUNNO:
     panic()

than:-

x.makeNoise()

?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list