FixedPoint
Jason Orendorff
jason at jorendorff.com
Sun Feb 10 23:42:02 EST 2002
> [Jason Orendorff]
> > Yep. If you know what's in _norm() you can do better than I
> > can. :) Also, you might pull the first return statement out
> > of the try.
>
> _norm basically pulls the number and the precision out of the FixedPoint
> instances. So that would give us this:
>
> def __cmp__(self, other):
> try:
> xn, yn, p = _norm(self, other)
> except TypeError:
> xn, yx = self, float(other)
> return cmp(xn, yn)
No, instead of "self, float(other)" it should be "float(self), other".
def __cmp__(self, other):
try:
xn, yn, p = _norm(self, other)
except TypeError:
xn, yn = float(self), other
return cmp(xn, yn)
This should work with None, and any other object that a float
can be compared with.
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list
mailing list