[Python-ideas] Rough draft: Proposed format specifier for a thousands separator (discussion moved from python-dev)
python at rcn.com
Mon Mar 16 07:05:42 CET 2009
> Raymond Hettinger wrote:
>> * Summarize commentary to date.
>> * Add APOSTROPHE and non-breaking SPACE to the list of separators.
>> * Add more links to external references.
>> * Detail issues with the locale module.
>> * Clarify how proposal II is parsed.
[Scott David Daniels]
> Still doesn't specify to digits beyond the decimal point.
Will clarify that the intent is to put thousands separators
only to the left of the decimal point.
> In particular, what should (format(9876.54321, "13,.5f"),
> format(9876.54321, "12,.4f")) produce?
> Possible "reasonable" answers:
> A ' 9,876.54321', ' 9,876.5432'
> B ' 9,876.543,21', ' 9,876.543,2'
> C ' 9,876.543,2', ' 9,876.543,'
> D ' 9,876.543,2', ' 9,876.543'
> I prefer B, but I can see an argument for any of the four above.
Am proposing A
That matches the existing precedent in the local module:
>>> locale.setlocale(locale.LC_ALL, 'English_United States.1252')
>>> locale.format("%15.8f", pi*1000, grouping=True)
It also matches what my adding have machines done, what my HP
calculator does, how excel handles thousands grouping, and the
other examples cited in the PEP.
Am thinking that anything else this would be a new, made-up requirement.
The closest I've seen to this is grouping of digits in long sequences
of pi and in logarithm tables. It may be useful to someone somewhere,
but am not going to propose it for the PEP.
More information about the Python-ideas