Python 3.0 - is this true?
Arnaud Delobelle
arnodel at googlemail.com
Sun Nov 9 14:39:25 EST 2008
"Martin v. Löwis" <martin at v.loewis.de> writes:
>> Even in 2.x it doesn't work (I think I posted this earlier but I'm not
>> sure anymore) as this example shows:
>>
>> 2 < 3j and 3j < True, but True < 2
>
> What specific value of x have you been trying? For x=4,5,6, I get
>
> py> 2 < 3j and 3j < True
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: no ordering relation is defined for complex numbers
>
> Regards,
> Martin
My example was using the comp function defined by Kay:
>> def comp(x1, x2):
>> try:
>> if x1<x2:
>> return -1
>> else:
>> return 1
>> except TypeError:
>> if str(x1)<str(x2):
>> return -1
>> else:
>> return 1
It just shows that it doesn't define an order for builtin types.
--
Arnaud
More information about the Python-list
mailing list