simplify > < etc in fraction

This commit is contained in:
Lafrite 2014-05-28 18:52:46 +02:00
parent 2e80eabb33
commit 43973a0039

View File

@ -197,17 +197,19 @@ class Fraction(object):
def __lt__(self, other): def __lt__(self, other):
""" < """ """ < """
if type(other) == Fraction: return float(self) < float(other)
return (self._num / self._denom) < (other._num / other._denom)
else:
return (self._num / self._denom) < other
def __le__(self, other): def __le__(self, other):
""" <= """ """ <= """
if type(other) == Fraction: return float(self) <= float(other)
return (self._num / self._denom) <= (other._num / other._denom)
else: def __gt__(self, other):
return (self._num / self._denom) <= other """ > """
return float(self) > float(other)
def __ge__(self, other):
""" >= """
return float(self) >= float(other)