[Python-Dev] Conditional Expression Resolution

Tim Peters tim.peters at gmail.com
Fri Sep 30 16:59:21 CEST 2005

> After a long discussion I've decided to add a shortcut conditional
> expression to Python 2.5.
> The syntax will be
>    A if C else B


> The priorities will be such that you can write
> ...
>   x = A if C else B if D else E

I assume this groups as

    A if C else (B if D else E)

rather than as

    (A if C else B) if D else E

?  So that C is evaluated first, and if C is true D isn't evaluated at all.


> Flames, pleas to reconsider, etc., to /dev/null.

Compared to the postfix

    A then C if B

it's a positive delight.

> Congratulations gracefully accepted.

Congratulations gracefully tendered.

> It's still my language! :-)

If that was in doubt, you just proved it <wink>.

More information about the Python-Dev mailing list