def d(_in, decimal_places=3):
    """ Convert number to Decimal and do rounding, for doing calculations
        Examples:
          46.18271  to   46.183   rounded up
          46.18749  to   46.187   rounded down
          117.34999999999999 to 117.350
         _rescale is a private function, bad practice yet works for now.
    """
return Decimal(_in)._rescale(-decimal_places, 'ROUND_HALF_EVEN')
Форматировать объект Python Decimal с указанной точностью