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

Lie Ryan lie.1296 at gmail.com
Wed Mar 18 14:41:56 CET 2009


Raymond Hettinger wrote:
> 
>>> What I've generally seen on cheques is $****1,000.00
>>
>> Interestingly, str.format will actually be able to produce directly in 
>> 3.1:
>>
>>  "${:*>,.2f}".format(value)
> 
> What we have already in SVN courtesy of Mark Dickinson:
> 
>>>> from decimal import Decimal
>>>> value = Decimal(1000)
>>>> "${:*>12,.2f}".format(value)
> '$****1,000.00'
> 

Anything but zeroes that isn't too similar to numeric character should 
be fine for "finance-related number".

PS: On this side of the world, the commas and the dots are reversed so I 
would not dream any solution that doesn't encompass at least that (which 
doesn't require additional function wrapping). I'd personally prefer 
fully customizable separator, as my personal preference is using space 
and decimal commas
PPS: I HAVE A HISTORY OF BEING ADMITTED TO A MENTAL INSTITUTION AFTER 
SEEING NUMBERS WITH COMMAS USED AS THOUSAND SEPARATOR.
PPPS: The next statement is a lie.
PPPPS: The mental institution thing is true.




More information about the Python-ideas mailing list