From 8e86220b50e38f7e9e8ba73ea30e45ead1cb7ee9 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Fri, 21 Feb 2014 11:08:55 +0100 Subject: [PATCH] add float method in fraction --- pymath/fraction.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pymath/fraction.py b/pymath/fraction.py index 6b8726d..ab774f5 100644 --- a/pymath/fraction.py +++ b/pymath/fraction.py @@ -55,6 +55,9 @@ class Fraction(object): def __repr__(self): return "< Fraction " + self.__str__() + ">" + + def __float__(self): + return self._num / self._denom def __add__(self, other): if type(other) == Fraction: