Ternary operator (Re: Ternery operator)

Michael Geary Mike at DeleteThis.Geary.com
Mon Sep 8 08:42:15 CEST 2003


> Andrew Chalk wrote:
> > Is there a python equivalent of the C ternery operator?

Peter Hansen wrote:
> See http://www.python.org/cgi-bin/faqw.py?query=4.16&req=search

As a newcomer to Python, I found it interesting to read the PEP for this:

http://www.python.org/peps/pep-0308.html

In retrospect, it seems obvious that the way the voting was conducted
insured that no ternary operator would be added to the language.

There were 16 proposed syntax options, and the requirement was that a
ternary operator would be added only if an clear majority picked a single
one of those options.

Well, with 16 options to choose from, it hardly seems surprising that none
achieved a majority-even though several of them drew quite a few votes, and
the most popular proposal did get more votes than the "reject all" option.

Four of the options got significantly more votes than the others. Those four
options combined got more than three times the number of votes that "reject
all" got.

It seems to me that the majority did want some kind of ternary operator, but
the large number of options prevented any one from being the clear winner. I
would wager that if the BDFL had picked his favorite from any of the most
popular options and said, "Now vote yes or no on *this* syntax", he would
have seen that clear majority he was looking for.

I suppose this is all water under the bridge now, since the PEP stated that
this was the community's one and only chance. I just can't help but think
that the voting system guaranteed the outcome--but it's Guido's language and
it was certainly his call to make.

-Mike (who just got my California voter's pamphlet with 135 candidates for
governor!)






More information about the Python-list mailing list