From 2869b809f62f260eee8ba7a8a74a031ade5dd048 Mon Sep 17 00:00:00 2001 From: Mario Alegre Date: Sat, 12 Dec 2020 18:59:46 -0500 Subject: [PATCH] first commit --- python/.gitignore | 1 + python/FracAndDec.py | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 python/.gitignore create mode 100644 python/FracAndDec.py diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/python/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/python/FracAndDec.py b/python/FracAndDec.py new file mode 100644 index 0000000..ac41dda --- /dev/null +++ b/python/FracAndDec.py @@ -0,0 +1,11 @@ +import decimal +import fractions + +class Dec(decimal.Decimal): + def __Fraction__(self): + return self.__new__(self.numerator) / self.__new__(self.denominator) + + getcontext = decimal.getcontext + +class Frac(fractions.Fraction): + pass