Merge Eric's proposal into proposal II.

This commit is contained in:
Raymond Hettinger 2009-03-13 02:55:13 +00:00
parent 6daa393c3a
commit 3612e2a2a3
1 changed files with 16 additions and 38 deletions

View File

@ -119,23 +119,29 @@ and decimal point::
format(1234.5, "08,.1f") --> '01,234.5' format(1234.5, "08,.1f") --> '01,234.5'
Proposal II (to meet Antoine Pitrou's request) Proposal II (from Eric Smith)
============================================== =============================
Make both the thousands separator and decimal separator user Make both the thousands separator and decimal separator user
specifiable but not locale aware. For simplicity, limit the specifiable but not locale aware. For simplicity, limit the
choices to a comma, period, space, or underscore. choices to a COMMA, DOT, SPACE, or UNDERSCORE.
[[fill]align][sign][#][0][width][T[tsep]][dsep precision][type] Whenever the separator is followed by a precision, it is a
decimal separator and the optional separator preceding it is a
thousands separator. When the precision is absent, the
context is integral and a lone specifier means a thousands
separator::
[[fill]align][sign][#][0][width][tsep|([tsep] dsep precision)][type]
Examples:: Examples::
format(1234, "8.1f") --> ' 1234.0' format(1234, "8.1f") --> ' 1234.0'
format(1234, "8,1f") --> ' 1234,0' format(1234, "8,1f") --> ' 1234,0'
format(1234, "8T.,1f") --> ' 1.234,0' format(1234, "8.,1f") --> ' 1.234,0'
format(1234, "8T ,f") --> ' 1 234,0' format(1234, "8 ,f") --> ' 1 234,0'
format(1234, "8d") --> ' 1234' format(1234, "8d") --> ' 1234'
format(1234, "8T,d") --> ' 1,234' format(1234, "8,d") --> ' 1,234'
This proposal meets mosts needs (except for people wanting This proposal meets mosts needs (except for people wanting
grouping for hundreds or ten-thousands), but it comes at the grouping for hundreds or ten-thousands), but it comes at the
@ -150,34 +156,6 @@ length including the thousands separators and decimal separators.
No change is proposed for the locale module. No change is proposed for the locale module.
Proposal III (from Eric Smith: like II but without the T)
=========================================================
In the second proposal, the *T* isn't strictly necessary.
In the context of an integer, an optional single specifier means
a thousands separator. In the context of a float, a single
specifier is a decimal separator while two specifiers are taken
as a thousands separator and a decimal separator::
[[fill]align][sign][#][0][width][tsep][dsep precision][type]
Examples::
format(1234, "8.1f") --> ' 1234.0'
format(1234, "8,1f") --> ' 1234,0'
format(1234, "8.,1f") --> ' 1.234,0'
format(1234, "8 ,f") --> ' 1 234,0'
format(1234, "8d") --> ' 1234'
format(1234, "8,d") --> ' 1,234'
This is a cleaner looking syntax but has the minor disadvantage of
using context to direct the translation. Whenever the separator
is followed by a precision, it is a decimal separator and the separator
preceding it is a thousands separator. When the precision is
absent, the context is integral and a lone specifier means
a thousands separator.
Other Ideas Other Ideas
=========== ===========