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

Eric S. Raymond esr@thyrsus.com
Sun, 30 Jan 2000 18:43:17 -0500


Tim Peters <tim_one@email.msn.com>:
> 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 have to say that I think any ternary syntax that mixes a single-character
operator with a keyword would be intolerably ugly.
 
> Now let's see whether people really want the functionality or are just
> addicted to C syntax <ahem>.

It's not that simple.  People clearly want the functionality; we've
seen ample evidence of that.  Given that, I think the presumption has
to be in favor of using the familiar C syntax rather than an invention
that would necessarily be more obscure.

> BTW, a number of other changes would be needed to the Lang Ref manual (e.g.,
> section 2.6 (Delimeters) explicitly says that "?" isn't used in Python
> today, and that its appeareance outside a string literal or comment is "an
> unconditional error"; etc).

I'm certainly willing to fix that.
-- 
		<a href="http://www.tuxedo.org/~esr">Eric S. Raymond</a>

[The disarming of citizens] has a double effect, it palsies the hand
and brutalizes the mind: a habitual disuse of physical forces totally
destroys the moral [force]; and men lose at once the power of
protecting themselves, and of discerning the cause of their
oppression.
        -- Joel Barlow, "Advice to the Privileged Orders", 1792-93