From f444a58a2b03fb13680a6e2a5426be802168dd9d Mon Sep 17 00:00:00 2001 From: Lafrite Date: Fri, 28 Feb 2014 08:49:03 +0100 Subject: [PATCH] Add abs method for Fraction --- pymath/fraction.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pymath/fraction.py b/pymath/fraction.py index 450fb59..74faa3d 100644 --- a/pymath/fraction.py +++ b/pymath/fraction.py @@ -273,6 +273,9 @@ class Fraction(object): return steps + def __abs__(self): + return Fraction(abs(self._num), abs(self._denom)) + def __eq__(self, other): """ == """ if type(other) == Fraction: