how to overload operator "< <" (a < x < b)?
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Fri Aug 7 11:02:13 EDT 2009
On 12:50 pm, benjamin.kaplan at case.edu wrote:
>On Fri, Aug 7, 2009 at 8:00 AM, dmitrey<dmitrey.kroshko at scipy.org>
>wrote:
>>hi all,
>>is it possible to overload operator "< <"? (And other like this one,
>>eg "<= <=", "> >", ">= >=")
>>Any URL/example?
>>Thank you in advance, D.
>
>That isn't an operator at all. Python does not support compound
>comparisons like that. You have to do "a > b and b > c".
That's partially correct. There is no "compound less than operator", or
whatever you want to call that. However, Python does support "compound
comparisons" like that:
>>> 1 < 2 < 3
True
>>> 1 < 3 < 2
False
>>> 1 == 2 == 3
False
>>> 2 == 2 == 2
True
>>>
Jean-Paul
More information about the Python-list
mailing list