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

Mark Dickinson dickinsm at gmail.com
Tue Mar 17 13:57:26 CET 2009

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)

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.


More information about the Python-ideas mailing list