[Python-Dev] Adding C ternary select (a?b:c) to Python?

Ka-Ping Yee ping@lfw.org
Sun, 30 Jan 2000 19:29:43 -0600 (EST)


On Sun, 30 Jan 2000, Tim Peters wrote:
> If this goes in (I'm not deadly opposed, just more opposed than in favor),
> I'd like to see "else" used instead of the colon (cond "?" true "else"
> false).  The question mark is reasonably mnemonic, but a colon makes no
> sense here.

I agree with that sentiment (along the lines of the philosophy that
chose "and" over "&&"), and it seems to me that it makes the most sense
to use words for both:

    a = x > 0 then x else -x

I don't have the time to do it right this second, but i suggest that
a scan through a decent chunk of Python would be useful to find out how
often this construct (in its "and"/"or" incarnation) actually gets used.
I promise to give it a try as soon as i get my notebook battery charged
up again.


-- ?!ng