4 ms·
wouldn't just from decimal import Decimal as d work as well?
by zokier 5y ago
wouldn't just
from decimal import Decimal as d
work as well?
- leetrout 5y agoSorry, I am doing stuff in the function... here is one of the old ones from code I can share def dec(value, prec=4): """Return the given value as a decimal rounded to the given precision.""" if value is None: return Decimal(0) value = Decimal(value) ret = Decimal(str(round(value, prec))) if ret.is_zero(): # this avoids stuff like Decimal('0E-8') return Decimal(0) return ret