Which is a clean way to write this formatting function:
def percent(value,digits=0):
return (\'{0:.%d%%}\' % digits).format(value)
>>> percent(
From the docs:
Minimum field width (optional). If specified as an '*' (asterisk), the actual width is read from the next element of the tuple in values, and the object to convert comes after the minimum field width and optional precision.
Example:
def percent(value, digits=0):
print '%.*f%%' % (digits, value*100)
>>> percent(0.1565, 2)
15.65%