FixedPoint

Jason Orendorff jason at jorendorff.com
Sat Feb 9 03:04:56 CET 2002


Mark McEahern wrote:
> I'm not sure what the best fix is here but one that works is to 
> modify the __cmp__ method for FixedPoint to anticipate comparison
> to None.  Here's the current __cmp__:
>
>     def __cmp__(self, other):
>         xn, yn, p = _norm(self, other)
>         return cmp(xn, yn)

How about:

    def __cmp__(self, other):
        try:
            xn, yn, p = _norm(self, other)
            return cmp(xn, yn)
        except:
            return cmp(float(self), other)

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list