Rough draft: Proposed format specifier for a thousands separator
Paul Rubin
http
Fri Mar 13 22:02:57 EDT 2009
Tim Rowe <digitig at gmail.com> writes:
> And if it's mostly for programmers' eyes, why does the motivation
> state that "Adding thousands separators is one of the simplest ways to
> improve the professional appearance and readability of output exposed
> to end users"?
It occurs to me, at least for quantities of data, one of the most
useful aids to readability is scaling down the quantity and suffixing
it with K (kilo), M (mega), G (giga), etc. This is sometimes done
with K=1000 and sometimes with K=1024 (fancy pronunciation "kibi"
rather than kilo, officially abbreviated Ki). Possible formatting:
'%.3K' % 1234567 = 1.235K # K = 1000
'%.:3Ki' % 1234567 = 1.206K # K = 1024
The colon (two dots) signifies base two. The "i" is not part of the
format spec, it's just a literal character, to make the standard
abbreviation for kibi.
More information about the Python-list
mailing list