Rough draft: Proposed format specifier for a thousands separator

Lie Ryan lie.1296 at gmail.com
Sat Mar 14 00:02:18 EDT 2009


Raymond Hettinger wrote:
> If anyone here is interested, here is a proposal I posted on the
> python-ideas list.
> 
> The idea is to make numbering formatting a little easier with the new
> format() builtin
> in Py2.6 and Py3.0:  http://docs.python.org/library/string.html#formatspec
> 
> 
> -------------------------------------------------------------
> 
> 
> Motivation:
> 
>    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.
> 
>    In the finance world, output with commas is the norm. Finance users and non-professional programmers find the locale approach to be frustrating, arcane and non-obvious.
> 
>    The locale module presents two other challenges. First, it is 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 (such as "de_DE") can vary from platform to platform or may not be defined at all. The docs for the locale module describe these and many other challenges [1] in detail.
> 
>    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 [2] . Instead, our goal is to make a common, everyday task easier for many users.



> 
> 
> 
> Comments and suggestions are welcome but I draw the line at supporting
> Mayan numbering conventions ;-)
> 
> 
> Raymond




More information about the Python-list mailing list