Hold on. We went down that road quite a bit and then discovered it wasn't going to work. The problem is that if you have two instance x, y such that isinstance(x, TotalOrdering) and isinstance(y, TotalOrdering) you still don't know if x < y is defined. (For example, if x is a string and y is a number.) We ended up deciding that such an ABC was not useful. There's a useful definition in there somewhere but it's elusive. We'll eventually figure it out.
On Feb 11, 2008 5:45 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > >> Was some thought given to providing a mixin for boolean > >> inequalities in total orderings (define __le__ and get > >> the rest for free) > > [GvR] > > IOW it's messy. > > Would it make sense to do something in numbers.py modeled > after Exact/InExact? Those don't have any behavior; they > just make a statement about semantics. > > > Raymond > > > --------------------------- > class TotalOrdering(object): > '''Equality and inequality operations on this type are guaranteed to > return boolean values and to imply a total ordering where the relations > are transitive (a<b and b<c implies a<c) and the operators have the > usual interrelationships: (a<b) == (b>a) == (not a>=b) == (not b<=a). > ''' > @abstractmethod > def __eq__(self, other): pass > > @abstractmethod > def __ne__(self, other): pass > > @abstractmethod > def __lt__(self, other): pass > > @abstractmethod > def __le__(self, other): pass > > @abstractmethod > def __gt__(self, other): pass > > @abstractmethod > def __ge__(self, other): pass > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ 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
