Function to add commas in numbers?

martynas sklizmantas saint at
Thu Jun 20 18:08:52 CEST 2002


On Thu, 2002-06-20 at 17:17, mdk wrote:
> Hello,
> Is there a function that will take, for example, 1234567 and return 
> 1,234,567?

you could use locale module
( )

for more interesting solutions look -

i have some problems with locale module on debian sid:

Python 2.1.3 (#1, Apr 20 2002, 10:14:34) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC, 'da_DK')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.1/", line 374, in setlocale
    return _setlocale(category, locale)
locale.Error: locale setting not supported

am i missing something in my installation?

best regards, 


You fill a much-needed gap.

More information about the Python-list mailing list