[Python-ideas] %-formatting with Decimals
Serhiy Storchaka
storchaka at gmail.com
Tue Mar 11 14:15:16 CET 2014
11.03.14 14:44, Oscar Benjamin написав(ла):
> Am I doing this wrong? Is this just a limitation of the old-style %
> formatting or something that could possibly be improved?
Yes, this is a limitation of the old-style % formatting. Another example:
>>> '{:.2f}'.format(1.234j)
'0.00+1.23j'
>>> '%.2f' % 1.234j
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert complex to float
More information about the Python-ideas
mailing list