PEP-308 left to right, a ? b else c

Marco Mariani marco at sferacarta.com
Mon Feb 17 07:16:44 EST 2003


On Sat, Feb 15, 2003 at 11:52:56PM +0100, Piet van Oostrum wrote:

> The "or" should be "but".
> But as "but" would be a new keyword, "except" may be better:
> 
> val = sqrt(x) except "imaginary" if x<0
> 
> Still I don't like it as the order isn't good. When there is a "normal"
> case and an "exceptional" case, OK, but if the true and false cases are
> more or less equally ocurring the if should be first.

Right to left would already be ugly, but I don't understand why Guido is
proposing a syntax which reads from the center to the border.

What's wrong with

a ? b else c


Maybe it already got proposed earlier in the thread, but I guess that:


1) it stands out more than the 'if' form when you're reading the expression
2) it reads left-to-right
3) you can't confuse it with the 'if' statement 






More information about the Python-list mailing list