miscellaneous programming tricks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
382 B

import decimal
from fractions import Fraction as Frac
class Dec(decimal.Decimal):
def __new__(cls,value="0",context=None):
if isinstance(value, Frac):
return super().__new__(cls,value.numerator,context) / super().__new__(cls,value.denominator,context)
else:
return super().__new__(cls,value,context)
getcontext = decimal.getcontext