On 28 January 2018 at 19:30, Stephan Houben
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 ".". One nice aspect of this suggestion is that supplying the comma would map directly to the "grouping" parameter in https://docs.python.org/3/library/locale.html#locale.format: >>> import locale >>> locale.setlocale(locale.LC_ALL, "en_IN.utf8") 'en_IN.utf8' >>> locale.format("%d", 10e9, grouping=True) '10,00,00,00,000' Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia