[Python-ideas] Rough draft: Proposed format specifier for a thousands separator (discussion moved from python-dev)

Scott David Daniels Scott.Daniels at Acm.Org
Sun Mar 15 21:41:38 CET 2009


Eric Smith wrote:
> Scott David Daniels wrote:
>> Still doesn't specify [how to deal with] digits beyond the decimal point....
>> what should (format(9876.54321, "13,.5f"), format(9876.54321, "12,.4f")) produce?
>>    A   '  9,876.54321', '  9,876.5432'
>>    B   ' 9,876.543,21', ' 9,876.543,2'
>>    C   '  9,876.543,2', '  9,876.543,'
>>    D   '  9,876.543,2', '   9,876.543'
>> I prefer B, but I can see an argument for any of the four above.
> 
> The C locale functions don't support grouping to the right of the 
> decimal. I don't think I've ever seen a system that supports it. Do you 
> have any examples?
I've only used separators to check digits below the decimal point.
Most high-precision tables of constants that I've seen use 5-digit
grouping (e.g. wikipedia for pi):
     3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37510
But 3 on the left and 5 on the right really seems to be too much.
> I'd say A.
For me, A and B are the "preferable" solutions; I just think
the PEP needs to say what it chooses.

--Scott David Daniels
Scott.Daniels at Acm.Org




More information about the Python-ideas mailing list