Levi wrote:
> Now, I understand that set doesn't return NotImplemented to avoid having
> it's __cmp__ method called, but what I don't get is why it has a __cmp__
> method at all. I thought the entire point of set and co. using the rich
> comparison operators is that Sets only define a partial ordering and so
> shouldn't define __cmp__, which implies a total ordering. So why define
> a __cmp__ method that only raises an error at the expense of breaking
> the rich comparison operators?
set() and frozenset() do this to prevent falling back to the default
ordering employed in Python 2.x:
>>> obj1 = type('T1', (), {})
>>> obj2 = type('T2', (), {})
>>> obj1 < obj2
True
>>> obj1 > obj2
False
It should be possible to make them play more nicely with others in 3.x
where that undesirable fallback behaviour is gone though.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
_______________________________________________
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