From 43973a0039e35be1b39e3731052b3901e567855b Mon Sep 17 00:00:00 2001 From: Lafrite Date: Wed, 28 May 2014 18:52:46 +0200 Subject: [PATCH] simplify > < etc in fraction --- pymath/fraction.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pymath/fraction.py b/pymath/fraction.py index e7ce547..d750709 100644 --- a/pymath/fraction.py +++ b/pymath/fraction.py @@ -197,17 +197,19 @@ class Fraction(object): def __lt__(self, other): """ < """ - if type(other) == Fraction: - return (self._num / self._denom) < (other._num / other._denom) - else: - return (self._num / self._denom) < other + return float(self) < float(other) def __le__(self, other): """ <= """ - if type(other) == Fraction: - return (self._num / self._denom) <= (other._num / other._denom) - else: - return (self._num / self._denom) <= other + return float(self) <= float(other) + + def __gt__(self, other): + """ > """ + return float(self) > float(other) + + def __ge__(self, other): + """ >= """ + return float(self) >= float(other)