Albert van der Horst
albert at spenarnc.xs4all.nl
Fri Jul 13 14:30:47 CEST 2012
In article <4ff0f8e0$0$29988$c3e8da3$5496439d at news.astraweb.com>,
Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>On Sun, 01 Jul 2012 05:55:24 -0400, Terry Reedy wrote:
>> 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.
>Apart from Python, Mathematica, Perl 6, CoffeeScript, Cobra and Clay give
>chained comparisons the standard meaning. It is, or was, a feature
>request for Boo, but I can't tell whether it has been implemented or not.
Algol 68 does not. It has promoted operator symbols to first
class citizens. In that context chained comparison operators
cannot be made to work.
Both Mathematica and Perl are ad-hoc-ish languages. I would
hate Python go that way.
>From now on, for each operator I would have to remember wether it
is a supposedly comparison operator or not.
Comparison operations on booleans make sense.
I remember a FORTRAN compiler complaining about me
comparing LOGICALS. The lack of abstraction!
>C-like semantics are next to useless, except perhaps for obfuscation:
>C-like semantics are a clear case of purity of implementation overruling
The worst of is, of course, = for assignment instead of := .
This is a convention that Python follows, to my dismay.
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
More information about the Python-list