(a==b) ? 'Yes' : 'No'
steve at holdenweb.com
Thu Apr 1 18:44:35 CEST 2010
> I've been following this thread for a few days now. My thoughts are
> that, in view of a long known widely used syntax for this operator,
> python's syntax seems like change for change sake. If current
> programing paradigm provides that particular trinary operator, why
> should python's be different from the previously well known one.
Because the "long known widely used syntax" has been responsible for
some of the most incomprehensible and buggy code in the known universe. \
> For instance, no reasonable language designer would, now, use post-fix
> (I know about Forth) or allow only +=, -=, /=, etc. assignments ONLY.
> (Just as no reasonable car designer would put the accelerator pedal on
> the left.) There are conventions which should span products. Yes
> python has the trinary operator and it's not going to change, but this
> seems like a bit of petulance on the part of the designer.
That argument could easily be extended to suggesting that there should
be no new languages at all. Guido made the specific choice of this
syntax precisely to try and ensure that the ternary (not trinary)
operator wasn't abused the way it has been in C (and later C#). He is a
language designer with a fine sense of readability, and I personally
respect his decision.
This StackOverflow thread
is just one example of the time that gets wasted.
But then I suppose that this thread just exemplifies that people will
find something else to waste their time on if you don't encourage them
to abuse the ternary operator.
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
More information about the Python-list