[Python-ideas] Automatic total ordering
George Sakkis
george.sakkis at gmail.com
Thu Oct 16 07:38:35 CEST 2008
On Thu, Oct 16, 2008 at 12:07 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> Guido van Rossum wrote:
>
>> On Wed, Oct 15, 2008 at 12:12 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>>
>
> interpret the above as saying that we have already done as much as is
>>> sensible (except for changing the docs).
>>>
>>
>> I think we've done as much as I am comfortable with doing *by default*
>> (i.e. when inheriting from object). The rest should be provided via
>> mix-ins. But even those mix-ins should wait until 3.1.
>>
>
> After posting and then thinking some more, I came to the same conclusion,
> that anything more should be by explicit request.
Can you expand on how you reached this conclusion ? For one thing, total
orderings are far more common, so that alone is a strong reason to have them
by default, even if it made things harder for partial orderings. Even for
those though, the current behavior is not necessarily better:
class SetlikeThingie(object):
def __init__(self, *items):
self.items = set(items)
def __eq__(self, other):
return self.items == other.items
def __ne__(self, other):
return self.items != other.items
def __lt__(self, other):
return self!=other and self.items.issubset(other.items)
>>> a = SetlikeThingie(1,2,3)
>>> b = SetlikeThingie(2,3,4)
>>> assert (a<b or a==b) == (a<=b)
AssertionError
George
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20081016/cb182f08/attachment.html>
More information about the Python-ideas
mailing list