add float method in fraction

This commit is contained in:
Lafrite 2014-02-21 11:08:55 +01:00
parent 1abd903c9b
commit 8e86220b50

View File

@ -55,6 +55,9 @@ class Fraction(object):
def __repr__(self): def __repr__(self):
return "< Fraction " + self.__str__() + ">" return "< Fraction " + self.__str__() + ">"
def __float__(self):
return self._num / self._denom
def __add__(self, other): def __add__(self, other):
if type(other) == Fraction: if type(other) == Fraction: