On 7/1/2012 2:54 AM, Steven D'Aprano wrote:

So no, Python has always included chained comparisons, and yes, it is
shameful that a language would force you to unlearn standard notation in
favour of a foolish consistency with other operators. Comparisons aren't
special because they return bools. They are special because of the way
they are used.

C treats comparison operators as if they were arithmetic operators, and
so the behaviour of a chained comparison is the same as the behaviour as
a sequence of arithmetic operators: a foolish consistency. Python treats
comparison operators as comparison operators, and gives them behaviour
appropriate to comparisons.

I considered this a great feature of Python when I first learned it. Reading about how rare it is among programming languages to treat comparisons in the standard way in mathematics reinforces that.

--
Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to