[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Would there be support for a more general cmp/__cmp__
From: Steven Bethard <steven.bethard () gmail ! com>
Date: 2005-10-26 16:05:31
Message-ID: n-Sdna7R34LbNMLeRVn-rA () comcast ! com
[Download RAW message or body]
Antoon Pardon wrote:
> Christopher Subich schreef :
>
>> Antoon Pardon wrote:
>>> >>>from decimal import Decimal
>>> >>>Zero = Decimal(0)
>>> >>>cmp( ( ) , Zero)
>>> -1
>>> >>>cmp(Zero, 1)
>>> -1
>>> >>>cmp(1, ( ) )
>>> -1
>>
>> I'd argue that the wart here is that cmp doesn't throw an exception, not
>> that it returns inconsistent results. This is a classic case of
>> incomparable objects, and saying that 1 < an empty tuple is bordering on
>> meaningless.
>
> I wont argue with you here, but it is what python gives as now.
> Changing this behaviour is not going to happen.
FWIW, Guido has said a few times that in Python 3.0 we should "Raise an
exception when making comparisons (other than equality and inequality)
between two incongruent types."[1] But yes, the behavior won't change
in the Python 2.X series due to backwards compatibility concerns.
STeVe
[1] http://wiki.python.org/moin/Python3%2e0
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic