Function to add commas in numbers?

martynas sklizmantas saint at ghost.lt
Thu Jun 20 12:08:52 EDT 2002


hello, 


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
(http://www.python.org/doc/current/lib/module-locale.html )

for more interesting solutions look -
http://mail.python.org/pipermail/python-list/2002-June/thread.html#108787


btw, 
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/locale.py", line 374, in setlocale
    return _setlocale(category, locale)
locale.Error: locale setting not supported


am i missing something in my installation?


best regards, 

ms

-- 
You fill a much-needed gap.






More information about the Python-list mailing list