On 3/20/07, Steven Bethard <[EMAIL PROTECTED]> wrote:
> I've used a __key__() method quite successfully in my own code.  Maybe
> we should provide a mixin like::
>
>     class KeyedComparisonMixin(object):
>         def __eq__(self, other):
>             return self.__key__() == other.__key__()
[snip]
>         def __ge__(self, other):
>             return self.__key__() >= other.__key__()

On 3/20/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> How would that produce the desired behavior that == and != are defined
> on all objects, but <, <=, >= and > are not?

The intent was that this would be a mixin like DictMixin -- not
default behavior at all. It's roughly parallel to what used to happen
when you defined __cmp__, so anyone that felt that defining __lt__,
__gt__, etc. was too tedious could "opt in" by adding the mixin to
their class bases.  I wasn't suggesting that this mixin should ever be
added implicitly by Python.

As far as Python 2.6 code goes, I think simply warning about any uses
of __cmp__ should be fine.  (I'd also be nervous about 2to3 generating
something like the code above automatically.)

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

Reply via email to