PEP 308: Alternative conditional operator forms
David Gausebeck
gausebec-spam at paypal.com
Sun Feb 9 20:46:14 EST 2003
>Here is the list I have so far (C represents the conditional expression,
>x the if-true expression, y the if-false one):
>
>x if C else y # initial proposition in PEP
>C ? x ! y # mentioned in PEP
>(if C then x else y) # mentioned in PEP
>x when C else y
>(if C: x else: y)
>C ? x else y
>C -> x else y
>C -> (x, y)
>
>What else should be on this list? (You can reply by email if you wish.)
Paul Rubin suggested
<new keyword> C: x else y
and I like it, but no one else seems to have commented either way.
The original suggestion was for a keyword of 'ifelse' or possibly
'select'. I would prefer 'when' or 'case':
ifelse C: x else y
when C: x else y
case C: x else y
-Dave
More information about the Python-list
mailing list