(a==b) ? 'Yes' : 'No'
steve at REMOVE-THIS-cybersource.com.au
Fri Apr 2 20:53:16 EDT 2010
On Fri, 02 Apr 2010 20:12:59 +0000, kj wrote:
> In <mailman.1326.1269971785.23598.python-list at python.org> Steve Holden
> <steve at holdenweb.com> writes:
>>Yes, that's deliberately awful syntax. Guido designed it that way to
>>ensure that people didn't aver-use it, thereby reducing the readability
>>of Python applications.
> Is that for real??? It's the QWERTY rationale all over again. Swell.
Not according to the PEP. No fewer than 16 alternatives were put to a
vote, and with no clear winner (but many obvious losers) Guido made the
Although the results of the voting are given, unaccountably no final
tally was given. Possibly because nobody could agree on how to tally the
votes. Using a simple counting procedure (I give 3 votes for a rank1
vote, 2 votes for a rank2 and 1 for a rank3, signed according to whether
it was an Accept or Reject vote) I find the top four candidates were:
C. (if C: x else: y) 27%
D. C ? x : y 20%
B. if C then x else y 13%
A. x if C else y 11%
with everything else an order of magnitude smaller (6% or less). If you
choose a different voting scheme, no doubt you will get different results.
Since no candidate syntax got a majority of the vote, it came down to the
only vote that really mattered: Guido's.
Ankh-Morpork had dallied with many forms of government
and had ended up with that form of democracy known as
One Man, One Vote. The Patrician was the Man; he had the
Vote. -- (T. Pratchett, "Mort")
Guido did say "Note that all these are intentionally ugly" but this was
followed by a smiley and was obviously tongue-in-cheek.
> "Let's preserve readability by making the syntax so ugly that people
> won't use it."??? That's just perverse. (It would have been more
> reassuring if the reason had been simply that Guido has an inexplicable
> dislike of ternary expressions just like one may have an inexplicable
> dislike of Broadway musicals.)
"Inexplicable"? They're musicals, and they're on Broadway. Surely that's
two good reasons to dislike them *wink*
> Second, sticking the test between the two alternatives goes against a
> vast tradition in programming languages.
As I've pointed out before, it is natural syntax in English. Not
necessarily the most common, but common enough to be completely
"I'll be there in ten minutes, if I can find a parking space close by,
otherwise you should start without me."
More information about the Python-list