FixedPoint

Jason Orendorff jason at jorendorff.com
Mon Feb 11 04:51:34 CET 2002


Mark McEahern wrote:
> [Jason Orendorff]
> > How about:
> >
> >     def __cmp__(self, other):
> >         try:
> >             xn, yn, p = _norm(self, other)
> >             return cmp(xn, yn)
> >         except:
> >             return cmp(float(self), other)
> 
> I like that!  Would it be better style to trap only the specific error I
> know about?

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.

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




More information about the Python-list mailing list