PEP 308: Alternative conditional operator forms

Paul Paterson hamonlypaulpaterson at houston.rr.com
Sun Feb 9 20:18:32 EST 2003


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3E46F0CE.5675E180 at alcyone.com...
> I'd like to build an exhaustive (or nearly so) of forms of the
> conditional operator that have been made so far that people have thought
> had _some_ merit (i.e., ones that were proposed and which someone other
> than the proponent indicated they thought might be a good idea), and
> those which Guido has not already absolutely dismissed (such as C ? x :
> y).  I'd like to do this both for my own edification in seeing them all
> in one place and for a potential second vote on the desired form (should
> the process get that far, of course).  (I'm also putting aside for the
> moment the issue of the introduction of new keywords or punctuation, or
> the appearance of chained conditional operators.)
>
> Note this is not a vote of any kind; the forms are listed in the very
> rough chronological order of them being suggested, with no other implied
> weighting on their position in the list.
>
> 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.)

y or x if C           # as in,  val = sqrt(x) or "imag" if x<0






More information about the Python-list mailing list