***locale.Error: unsupported locale setting***

Anurag Chourasia anurag.chourasia at gmail.com
Thu Dec 9 17:31:04 EST 2010


Hi All,

When i try to set a locale manually, i get this error.

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'es_cl.iso88591')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

On my OS, when i run the locale -a command, i get this output
-------------------------
*locale -a*
C
POSIX
en_US
en_US.8859-15
en_US.ISO8859-1
-------------------------
Does this means that on my machine, Python will be able to make use of above
listed locales?

*If yes then how can i possibly use the locale.setformat (or anything else
for that matter) to group numbers using '.' as the thousands separator?*

If i use the locale en_US then ',' is the thousands separator.

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US')
'en_US'
>>> locale.format("%d", 1255000, grouping=True)
'1,255,000'

Regards,
Anurag
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101210/c2853282/attachment-0001.html>


More information about the Python-list mailing list