What's the value of "None" between 2.1.1 and 1.5.2

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Fri Nov 30 18:05:06 EST 2001


On Fri, 30 Nov 2001 08:59:21 -0500, Steve Holden <sholden at holdenweb.com> wrote:
>"Michael Abbott" <michael at rcp.co.uk> wrote in message
>news:Xns91697EB73ACCmichaelrcpcouk at 194.238.50.13...
>> Skip Montanaro <skip at pobox.com> wrote in
>> news:mailman.1007090560.18985.python-list at python.org:
>>
>> > You were relying on undocumented behavior.  There is no obvious ordering
>> > between integers and None.
>> >
>>
>> So why don't comparisons of this type generate an exception?
>
>Because comparisons are used in sorts, for example, and it wasn't considered
>helpful for sorts of lists of arbitrary datatypes to raise errors.

However, sort will fail if one of the objects is a complex number.

The current order model is broken: the system can't make up its mind whether
it wants a total order or partial order.

Both kind of orders are used in practice. The only way to avoid unexpected
results in all cases is to assign distinct semantics to distinct syntax.  It
cannot be fixed by pretending there is only one kind of order.

One approach might be this: let sort use a total order defined by __cmp__,
and let max and min use a partial order defined by __lt__, __gt__.  The user
is responsible for their compatibility if so desired, but it should not be
required a priori.

Huaiyu



More information about the Python-list mailing list