[Python-ideas] Yet Another Switch-Case Syntax Proposal
Joao S. O. Bueno
jsbueno at python.org.br
Fri Apr 18 17:03:07 CEST 2014
On 17 April 2014 16:14, Lucas Malor <7vsfeu4pxg at snkmail.com> wrote:
> A simpler example:
>
> switch tarot case 0:
> card = "Fool"
> elcase 1:
> card = "Alan Moore"
> elcase 2:
> card = "High Priestess"
> <etc....>
It may be just me, but I fail - in a complete manner - to see how this
syntax can offer any
improvement on current if/elif chains. It seems to differ from that
only by reducing
the explicitness, and the flexibility of the test condition that can
be used in any
of the subconditions,
No, sorry, unlike others have mentioned, I don't find this
particularly "sexy". "Clumky"
is more like it:
if tarot ==0:
card = "Fool"
elif tarot == 1:
card = "Alan Moore"
elif 2 < tarot < 22: # expressiveness
card = "Surprise"
else:
raise ValueError
The implicit "in" operation case is even more weird.
js
-><-
More information about the Python-ideas
mailing list