variable number of digit in format string
<p>Which is a clean way to write this formatting function:</p>

<pre><code>def percent(value,digits=0):
    return ('{0:.%d%%}' % digits).format(value)

&gt;&gt;&gt; percent(0.1565)
'16%'

&gt;&gt;&gt; percent(0.1565,2)
'15.65%'
</code></pre>

<p>the problem is formatting a number with a given number of digits, I don't like to use both '%' operator and format method.</p>
