[Python-checkins] r64952 - peps/trunk/pep-3101.txt

Eric Smith eric at trueblade.com
Mon Jul 14 19:21:45 CEST 2008


>>> I would *really* like to see some way to specify a thousands separator.
>>>  Going through the locale module is a pita for this
>>> common need.
>>
>> Use the 'n' formatter. Admittedly, you have to have already set the
>> correct locale.
>
> Would it be too much to have a non-locale version so you could specify
> commas, dots, spaces, underscores, squiggles, etc.?
> Financial users of Python despair at the difficulties in formatting with
> separators.

The code's all there.  It's just a matter of deciding on an API and doing
some refactoring.  The code is in Objects/stringlib/localeutil.h. 
Basically you need to specify the thousands separator, and an array that
describes the groupings.  These two things are what is specified by the
locale.  If you also want to do the same for floats, you need to specify
what the decimal point string is.

If you can get agreement on an API, I'll implement it.

It's also easy to implement in Python.  The _group code in locale.py could
also be refactored to do the work.



More information about the Python-checkins mailing list