<div class="gmail_quote">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">But the biggest thing missing is precise semantics. Saying "exactly<br>the same semantics as with Python
2.5" doesn't cut it (those semantics<br>are incredibly hairy and sometimes surprising, and their<br>implementation was a nightmare -- I've rarely been as relieved as when<br>I was able to cut those out of the implementation).
</blockquote>
<div> </div>
<div>Why is that so? I might be being naive, but what is wrong with something like this:</div>
<div> </div>
<div>def cmp(a, b):<br> if hasattr(a, '__cmp__'):<br> return a.__cmp__(b)<br> elif hasattr(b, '__cmp__'):<br> return -1 * b.__cmp__(a)<br> elif hasattr(a, '__le__') and hasattr(a, '__ge__'):
<br> x = a <= b<br> y = a >= b<br> if x and y:<br> return 0<br> elif x:<br> return -1<br> elif y:<br> return 1<br> elif hasattr(b, '__le__') and hasattr(b, '__ge__'):
<br> x = b <= a<br> y = b >= a<br> if x and y:<br> return 0<br> elif x:<br> return 1<br> elif y:<br> return -1<br> elif hasattr(a, '__eq__'):
<br> if a == b:<br> return 0<br> if hasattr(a, '__lt__'):<br> if a < b:<br> return -1<br> else:<br> return 1<br> elif hasattr(a, '__gt__'):
<br> if a > b:<br> return 1<br> else:<br> return -1<br> else:<br> raise NotImplemented()<br> elif hasattr(b, '__eq__'):<br> if a == b:
<br> return 0<br> if hasattr(b, '__lt__'):<br> if b < a:<br> return 1<br> else:<br> return -1<br> elif hasattr(b, '__gt__'):<br>
if b > a:<br> return -1<br> else:<br> return 1<br> else:<br> raise NotImplemented()<br> else:<br> raise NotImplemented()</div></div>