how to overload operator "< <" (a < x < b)?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Aug 7 23:31:46 EDT 2009
On Fri, 07 Aug 2009 08:04:22 -0700, Scott David Daniels wrote:
> Benjamin Kaplan wrote:
>> .... Python does not support compound comparisons like that. You have
>> to do "a > b and b > c".
>
> Funny, my python does. This has been around a long time. I am not
> certain whether 1.5.2 did it, but "chained comparisons" have been around
> for a long time.
Yes it does:
$ python1.5
Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat
4.1.2-27)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>
>>> 2 < 3 < 4
1
Remembering that back then, 0 and 1 were used instead of False and True.
--
Steven
More information about the Python-list
mailing list