[Python-ideas] Rough draft: Proposed format specifier for a thousands separator (discussion moved from python-dev)
eric at trueblade.com
Tue Mar 17 15:56:07 CET 2009
Mark Dickinson wrote:
> On Tue, Mar 17, 2009 at 11:04 AM, Greg Ewing
> <greg.ewing at canterbury.ac.nz> wrote:
>> [...] as it looks decidedly weird, but if I had
>> to pick a meaning for format(1234, "08,d") I think
>> I would make it
>> ' 001,234'
> Yes, that looks better than either of the alternatives I gave.
> I think I prefer that commas *do* appear in the zero padding, though
> as Eric says, it does add some extra complication to the code. In
> the case of the decimal code that complication is significant, mainly
> because of the need to figure out how much space is available
> for the zeros *before* doing the comma insertion.
If you look at _PyString_InsertThousandsGrouping, you'll see that it
gets called twice. Once to compute the size, and once to actually do the
More information about the Python-ideas