> > But the biggest thing missing is precise semantics. Saying "exactly > the same semantics as with Python 2.5" doesn't cut it (those semantics > are incredibly hairy and sometimes surprising, and their > implementation was a nightmare -- I've rarely been as relieved as when > I was able to cut those out of the implementation).
Why is that so? I might be being naive, but what is wrong with something like this: def cmp(a, b): if hasattr(a, '__cmp__'): return a.__cmp__(b) elif hasattr(b, '__cmp__'): return -1 * b.__cmp__(a) elif hasattr(a, '__le__') and hasattr(a, '__ge__'): x = a <= b y = a >= b if x and y: return 0 elif x: return -1 elif y: return 1 elif hasattr(b, '__le__') and hasattr(b, '__ge__'): x = b <= a y = b >= a if x and y: return 0 elif x: return 1 elif y: return -1 elif hasattr(a, '__eq__'): if a == b: return 0 if hasattr(a, '__lt__'): if a < b: return -1 else: return 1 elif hasattr(a, '__gt__'): if a > b: return 1 else: return -1 else: raise NotImplemented() elif hasattr(b, '__eq__'): if a == b: return 0 if hasattr(b, '__lt__'): if b < a: return 1 else: return -1 elif hasattr(b, '__gt__'): if b > a: return -1 else: return 1 else: raise NotImplemented() else: raise NotImplemented()
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com