[Python-Dev] Formatting mini-language suggestion

Nick Coghlan ncoghlan at gmail.com
Thu Mar 12 04:40:02 CET 2009


Raymond Hettinger wrote:
> 
> [James Y Knight]
>> You might be interested to know that in India, the commas don't come 
>> every 3 digits. In india, they come every two digits, after the first 
>> three. Thus one billion = 1,00,00,00,000. How are you gonna represent 
>> *that* in a formatting mini-language? :)
> 
> It is not the goal to replace locale or to accomodate every
> possible convention.  The goal is to make a common task easier
> for many users.  The current, default use of the period as a decimal
> point has not proven to be problem eventhough that convention is
> not universal.   For a thousands separator, a comma is a decent choice
> that makes it easy follow-on with s.replace(',', '_') or somesuch.

In that case, I would simplify my suggestion to:

  [[fill]align][sign][#][0][minimumwidth][,][.precision][type]

Addition to mini language documentation:
  The ',' option indicates that commas should be included in the
 output as a thousands separator. As with locales which do not use a
 period as the decimal point, locales which use a different convention
 for digit separation will need to use the locale module to obtain
 appropriate formatting.

Guido has asked for a PEP to be developed on python-ideas to define the
deliberately limited scope though, so I'm going to bow out of the
conversation now...

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list