On 10/30/07, Adam Olsen <[EMAIL PROTECTED]> wrote:
> cmp and __cmp__ are doomed, due to unorderable types now raising exceptions:
>
> >>> cmp(3, 'hello')
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: unorderable types: int() < str()
> >>> 3 == 'hello'
> False
>
> A mixin for __cmp__ would be sufficient for scalars (where you can
> avoid this exception and your size is constant), but not for
> containers (which need to avoid inappropriate types and wish to avoid
> multiple passes.)
I don't understand this conclusion. If you start comparing things
that are unorderable, you'll get an exception. But cmp() still makes
sense when you compare other things::
>>> cmp((1, 'a', 4.5), (1, 'a', 6.2))
-1
>>> cmp([6, 5, 4], [6, 4, 5])
1
I definitely don't want any cmp/__cmp__ implementation that swallows
exceptions when the types don't align, e.g.::
>>> cmp((1, 'a'), ('a', 1))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: int() < str()
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com