* Minor edits/typos.

* Link to Babel project.
This commit is contained in:
Raymond Hettinger 2009-03-13 23:52:26 +00:00
parent 964ee28e3f
commit 860dd1ab3b
1 changed files with 18 additions and 18 deletions

View File

@ -18,8 +18,7 @@ Provide a simple, non-locale aware way to format a number
with a thousands separator.
Adding thousands separators is one of the simplest ways to
improve the professional appearance and readability of output
exposed to end users.
improve the professional appearance and readability of output.
In the finance world, output with commas is the norm. Finance
users and non-professional programmers find the locale
@ -30,14 +29,17 @@ a global setting and not suitable for multi-threaded apps that
need to serve-up requests in multiple locales. Second, the
name of a relevant locale (perhaps "de_DE") can vary from
platform to platform or may not be defined at all. The docs
for the locale module describe these and `other challenges`_
for the locale module describe these and `many other challenges`_
in detail.
.. _`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 locale or to accommodate every
possible convention. The goal is to make a common task easier
for many users.
It is not the goal to replace the locale module or to
accommodate every possible convention. Such tasks are better
suited to robust tools like `Babel`_ . Instead, our goal is to
make a common, everyday task easier for many users.
.. _`Babel`: http://babel.edgewall.org/
Current Version of the Mini-Language
@ -81,7 +83,7 @@ specifiers like::
`Common Lisp`_ uses a COLON before the ``~D`` decimal type specifier to
emit a COMMA as a thousands separator. The general form of ``~D`` is
``~mincol,padchar,commachar,commaintervalD``. The *padchar* defaults
to SPACE. The *commachar* defaults to COLON. The *commainterval*
to SPACE. The *commachar* defaults to COMMA. The *commainterval*
defaults to three.
::
@ -137,9 +139,9 @@ Proposal II (from Eric Smith)
Make both the thousands separator and decimal separator user
specifiable but not locale aware. For simplicity, limit the
choices to a COMMA, DOT, SPACE, APOSTROPHE or UNDERSCORE.
The SPACE can be eitherU +0020 or U+00A0.
The SPACE can be either U+0020 or U+00A0.
Whenever the separator is followed by a precision, it is a
Whenever a separator is followed by a precision, it is a
decimal separator and an optional separator preceding it is a
thousands separator. When the precision is absent, a lone
specifier means a thousands separator::
@ -156,10 +158,8 @@ Examples::
format(1234, "8,d") --> ' 1,234'
format(1234, "8_d") --> ' 1_234'
This proposal meets mosts needs (except for people wanting
grouping for hundreds or ten-thousands), but it comes at the
expense of being a little more complicated to learn and
remember.
This proposal meets mosts needs , but it comes at the expense
of being a little more complicated to learn and remember.
As shown in the examples, the *width* argument means the total
length including the thousands separators and decimal separators.
@ -172,7 +172,7 @@ Comparison
The difference between the two proposals is that the first is hard-wired
to a COMMA for a thousands separator and a DOT as a decimal separator.
The second allows either separator to be one of four possibilities.
The second allows either separator to be one of several possibilities.
@ -187,8 +187,8 @@ Other Ideas
* Eric Smith would like the C version of the mini-language
parser to be exposed with hooks that would make it easier
to write custom __format__ methods. That way
Decimal.__format__ would not have to be written from scratch.
to write custom *__format__* methods. That way, methods like
*Decimal.__format__* would not have to be written from scratch.
* Antoine Pitrou noted that the provision for a SPACE separator
should also allow a non-breaking space (U+00A0).
@ -214,7 +214,7 @@ Commentary
individual format strings makes it hard to change that convention
later. No workable alternative was suggested but the general idea
is to set the convention once and have it apply everywhere (others
commented that locale already does this).
commented that locale already provides a way to do this).
Copyright