Add __eq__ in fraction

This commit is contained in:
Lafrite 2014-02-21 18:02:34 +01:00
parent 49b224bedc
commit 6509e0164a

View File

@ -166,13 +166,24 @@ class Fraction(object):
return steps
def __eq__(self, other):
""" == """
if type(other) == Fraction:
number = other
else:
number = Fraction(other)
return self._num * number._denom == self._denom * number._num
def __lt__(self, other):
""" < """
if type(other) == Fraction:
return (self._num / self._denom) < (other._num / other._denom)
else:
return (self._num / self._denom) < other
def __le__(self, other):
""" <= """
if type(other) == Fraction:
return (self._num / self._denom) <= (other._num / other._denom)
else: