Defending the ternary operator
Aahz
aahz at pythoncraft.com
Sat Feb 8 17:36:46 EST 2003
In article <mailman.1044729201.7115.python-list at python.org>,
Andrew Koenig <ark at research.att.com> 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 pythoncraft.com) <*> http://www.pythoncraft.com/
Register for PyCon now! http://www.python.org/pycon/reg.html
More information about the Python-list
mailing list