Clarify that the PEP intent is not to serve as an
internationalization tool or to accommodate every possible convention. It intends to provide a generally useful tool for improving readability in many contexts. Also, clarify the groupings are for the integer part of a number. Digits to the right of the decimal point are unchanged.
This commit is contained in:
parent
dc3abfc0d3
commit
74e39f49b6
31
pep-0378.txt
31
pep-0378.txt
|
@ -35,7 +35,8 @@ in detail.
|
||||||
|
|
||||||
.. _`many other challenges`: http://docs.python.org/library/locale.html#background-details-hints-tips-and-caveats
|
.. _`many other challenges`: http://docs.python.org/library/locale.html#background-details-hints-tips-and-caveats
|
||||||
|
|
||||||
It is not the goal to replace the locale module or to
|
It is not the goal to replace the locale module, to perform
|
||||||
|
internationalization takes, or
|
||||||
accommodate every possible convention. Such tasks are better
|
accommodate every possible convention. Such tasks are better
|
||||||
suited to robust tools like `Babel`_ . Instead, our goal is to
|
suited to robust tools like `Babel`_ . Instead, our goal is to
|
||||||
make a common, everyday task easier for many users.
|
make a common, everyday task easier for many users.
|
||||||
|
@ -59,12 +60,6 @@ Research so far
|
||||||
Scanning the web, I've found that thousands separators are
|
Scanning the web, I've found that thousands separators are
|
||||||
usually one of COMMA, DOT, SPACE, APOSTROPHE or UNDERSCORE.
|
usually one of COMMA, DOT, SPACE, APOSTROPHE or UNDERSCORE.
|
||||||
|
|
||||||
James Knight observed that Indian/Pakistani numbering systems
|
|
||||||
group by hundreds. Ben Finney noted that Chinese group by
|
|
||||||
ten-thousands. Eric Smith pointed-out that these are already
|
|
||||||
handled by the "n" specifier in the locale module (albeit only
|
|
||||||
for integers).
|
|
||||||
|
|
||||||
Visual Basic and its brethren (like `MS Excel`_) use a completely
|
Visual Basic and its brethren (like `MS Excel`_) use a completely
|
||||||
different style and have ultra-flexible custom format
|
different style and have ultra-flexible custom format
|
||||||
specifiers like::
|
specifiers like::
|
||||||
|
@ -157,8 +152,11 @@ Examples::
|
||||||
format(1234, "8,d") --> ' 1,234'
|
format(1234, "8,d") --> ' 1,234'
|
||||||
format(1234, "8_d") --> ' 1_234'
|
format(1234, "8_d") --> ' 1_234'
|
||||||
|
|
||||||
This proposal meets mosts needs , but it comes at the expense
|
This proposal meets mosts needs, but it comes at the expense
|
||||||
of being a little more complicated to learn and remember.
|
of taking a bit more effort to parse. Not every possible
|
||||||
|
convention is covered, but at least one of the options (spaces
|
||||||
|
or underscores) should be readable, understandable, and useful
|
||||||
|
to folks from many diverse backgrounds.
|
||||||
|
|
||||||
As shown in the examples, the *width* argument means the total
|
As shown in the examples, the *width* argument means the total
|
||||||
length including the thousands separators and decimal separators.
|
length including the thousands separators and decimal separators.
|
||||||
|
@ -220,6 +218,21 @@ Commentary
|
||||||
is to set the convention once and have it apply everywhere (others
|
is to set the convention once and have it apply everywhere (others
|
||||||
commented that locale already provides a way to do this).
|
commented that locale already provides a way to do this).
|
||||||
|
|
||||||
|
* There are some precedents for grouping digits in the fractional
|
||||||
|
part of a floating point number, but this PEP does not venture into
|
||||||
|
that territory. Only digits to the left of the decimal point are
|
||||||
|
grouped. This does not preclude future extensions; it just focuses
|
||||||
|
on a single, generally useful extension to the formatting language.
|
||||||
|
|
||||||
|
* James Knight observed that Indian/Pakistani numbering systems
|
||||||
|
group by hundreds. Ben Finney noted that Chinese group by
|
||||||
|
ten-thousands. Eric Smith pointed-out that these are already
|
||||||
|
handled by the "n" specifier in the locale module (albeit only
|
||||||
|
for integers). This PEP does not attempt to support all of those
|
||||||
|
possibilities. It focuees on a single, relatively common grouping
|
||||||
|
convention that offers a quick way to improve readability in many
|
||||||
|
(though not all) contexts.
|
||||||
|
|
||||||
|
|
||||||
Copyright
|
Copyright
|
||||||
=========
|
=========
|
||||||
|
|
Loading…
Reference in New Issue