Case Statements

Mark Lawrence breamoreboy at yahoo.co.uk
Tue Mar 15 19:11:17 EDT 2016


On 15/03/2016 20:46, jj0gen0info at gmail.com wrote:
> Given that "Case Statements" are more compact and less redundant than a sequence of if-elif statements, and usually can contain embedded match lists:
> Is there any chance future versions of Python will adopt a case structure?
>
> Something like
>
> select x
>     case in [1,2,3,5,7,9]
>     print ....
>     case in [4,6,8]
>     print ....
>     case else
>     print ....
>
> Just a thought.
>
> JJ
>

Been suggested and rejected via 
https://www.python.org/dev/peps/pep-3103/ and 
https://www.python.org/dev/peps/pep-0275/.  The "Rejection Notice" 
section of the former states "A quick poll during my keynote 
presentation at PyCon 2007 shows this proposal has no popular support. I 
therefore reject it.".

See also http://c2.com/cgi/wiki?SwitchStatementsSmell

-- 
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