Defending the ternary operator

Aahz aahz at
Sat Feb 8 23:36:46 CET 2003

In article <mailman.1044729201.7115.python-list at>,
Andrew Koenig  <ark at> wrote:
>Or -- and this is what really convinces me -- I can write
>    z = x > y and x or y
>which looks really cool, and is just plain wrong, because if x is
>0 and y is negative, the result is 0 instead of y.
>It's this last example that really horrifies me, because people see
>it, think that "if a then b else c" should be written as
>"a and b or c", and then get into trouble.
>The fact that people are suggesting such circumlocutions says to me
>that there is a use for the feature, and the fact that people are
>suggesting incorrect circumlocutions makes my skin crawl.

Then attack the problem at its roots: flame the people who suggest such
circumlocutions instead of more Pythonic idioms.  </half-joking>
Aahz (aahz at           <*>

Register for PyCon now!

More information about the Python-list mailing list