[Python-ideas] Format mini-language for lakh and crore

Eric V. Smith eric at trueblade.com
Sun Jan 28 08:46:10 EST 2018


On 1/28/2018 6:51 AM, Nick Coghlan wrote:
> On 28 January 2018 at 19:30, Stephan Houben <stephanh42 at gmail.com> wrote:
>> Hi David,
>>
>> Perhaps the "n" locale-dependent number formatting specifier
>> should accept a , to have locale-appropriate formatting of thousand
>> separators?
>>
>> f"{x:,n}"
>>
>> would Do The Right Thing(TM) depending on the locale.
> 
> Checking https://www.python.org/dev/peps/pep-0378/, we did suggest
> using the locale module for cases where the engineering style
> groups-of-three structure wasn't appropriate, with the parallel being
> drawn to the fact that you also need to use locale dependent
> formatting to get a decimal separator other than ".".

If I recall correctly, we discussed this at the time, and the problem 
with locale is that it's not thread safe. I agree that if it were, it 
would be nice to be able to use it, either with 'n', or in some other 
mode just for grouping.

The underlying C setlocale()/localeconv() just isn't very friendly to 
this use case.

Eric.


More information about the Python-ideas mailing list