[Python-ideas] Rough draft: Proposed format specifier for a thousands separator (discussion moved from python-dev)

Raymond Hettinger python at rcn.com
Tue Mar 17 00:25:58 CET 2009


> Argh! So "8,1f" means "use comma instead of point" wherease "8,1d"
> means "use comma as 1000 separator"?

They both mean use the comma for the thousands separator.  The decimal separator only gets overridden as part of the precision 
specification if provided:      format(1234, "8,1f")     -->    '  1234,0'

Originally, I proposed prefixing the thousands separator with the letter T:      format(1234, "8T,d")      -->    '   1,234'.  That 
made it crystal clear that the next character was the thousands separator.  But people found it to be ugly and reacted badly.  Eric 
then noticed that the T wasn't essential as long as the decimal separator is tightly associated with the precision specifier.

If you find that to be screwy, then I guess Nick comma-only alternative wins.

Or, there is an alternative that is a little more flexible.  Make the thousands separator one of SPACE, UNDERSCORE, COMMA, or 
APOSTROPHE, leaving out the DOT which is reserved to be the sole decimal separator.  That is unambiguous but doesn't help folks who 
want both a DOT thousands separator and COMMA decimal separator.


Raymond 




More information about the Python-ideas mailing list