parameters: (f, p=0)
return_statement: return string
docstring: Set float precision and trim precision zeros.
docstring_summary: Set float precision and trim precision zeros.
docstring_tokens: Set float precision and trim precision zeros .
function: def fmt_float(f, p=0):
      """Set float precision and trim precision zeros."""
  
      string = str(
          decimal.Decimal(f).quantize(decimal.Decimal('0.' + ('0' * p) if p > 0 else '0'), decimal.ROUND_HALF_UP)
      )
  
      m = re_float_trim.match(string)
      if m:
          string = m.group('keep')
          if m.group('keep2'):
              string += m.group('keep2')
      return string
function_tokens: def fmt_float ( f , p = 0 ) : string = str ( decimal . Decimal ( f ) . quantize ( decimal . Decimal ( '0.' + ( '0' * p ) if p > 0 else '0' ) , decimal . ROUND_HALF_UP ) ) m = re_float_trim . match ( string ) if m : string = m . group ( 'keep' ) if m . group ( 'keep2' ) : string += m . group ( 'keep2' ) return string