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

Eric Smith eric at trueblade.com
Tue Mar 17 14:24:04 CET 2009

Mark Dickinson wrote:
> On Tue, Mar 17, 2009 at 11:15 AM, Eric Smith <eric at trueblade.com> wrote:
>> Hmm. No good answers here. I'd vote for not putting the commas in the
>> leading zeros.  I don't think anyone would ever actually use this
>> combination, and putting commas there complicates things due to the special
>> case with the first digit.
>> Plus, they're not inserted by the 'n' formatter, and no one has complained
>> (which might mean no one's using it, of course).
> But they *are* inserted by locale.format, and
> presumably no-one has complained about that either. :-)
>>>> format('%014f', 123.456, grouping=1)
> '0,000,123.456000'
> It appears that locale.format adds the thousand separators after
> the fact, so the issue with the leading comma doesn't come up.
> That also means that the relationship between the field width (14
> in this case) and the string length (16) is somewhat obscured.

Ick. Presumably you specified a width because that's how wide you wanted 
the output to be!

I still like leaving the commas out of leading zeros.

More information about the Python-ideas mailing list