title: Pythonic way to round a float to specific min AND max number of decimal places
body: <p>I would like to implement a function <code>round(num, min, max)</code> that rounds a float to at least <code>min</code> decimal places and at most <code>max</code>. I want it to return a string. I have something that works, but it was surprisingly long. Can you write something more pythonic than me?</p>
  
  <p>Usage</p>
  
  <pre><code>round(3.14159, 2, 4) --&gt; '3.1416'
  round(3.14159, 0, 2) --&gt; '3.14'
  round(3.14159, 0, 1) --&gt; '3.1'
  round(3.14159, 0, 0) --&gt; '3'
  round(3.14159, 4, 6) --&gt; '3.141590'
  round(3.14, 4, 6)    --&gt; '3.1400'
  round(3, 4, 6)       --&gt; '3.0000'
  </code></pre>
  
  <p>I think you get the idea. Here's what I've got.</p>
  
  <pre><code>def normalize(amount, min=0, max=2):
      """
      Rounds to a variable number of decimal places - as few as necessary in the range [min,max]
      :param amount: A float, int, decimal.Decimal, or string.
      :param min: the minimum number of decimal places to keep
      :param max: the maximum number of decimal places to keep
      :return: string.
      """
      if not amount:
          return amount
  
      # To Decimal, round to highest desired precision
      d = round(Decimal(amount), max)
      s = str(d)
  
      # Truncate as many extra zeros as we are allowed to
      for i in range(max-min):
          if s[-1] == '0':
              s = s[:-1]
  
      # Lose a trailing decimal point.
      if s[-1] == '.':
          s = s[:-1]
  
      return s
  </code></pre>