On 17 April 2014 16:14, Lucas Malor firstname.lastname@example.org 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.