Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: ***locale.Error: unsupported locale setting***

Reply
Thread Tools

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

 
 
Vlastimil Brom
Guest
Posts: n/a
 
      12-09-2010
2010/12/9 Anurag Chourasia <(E-Mail Removed)>:
> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

Hi,
I am not sure, it helps in your case, but the simple locale aliases
(like "Spanish") seem to work for me (py 2.7.1, win 7)

>>> locale.getlocale()

('Czech_Czech Republic', '1250')
>>> locale.localeconv()['thousands_sep']

'\xa0'
>>> locale.setlocale(locale.LC_ALL, "Spanish")

'Spanish_Spain.1252'
>>> locale.localeconv()['thousands_sep']

'.'
>>> locale.format("%d", 1255000, grouping=True)

'1.255.000'
>>>


hth,
vbr
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Module locale throws exception: unsupported locale setting Sibylle Koczian Python 2 11-20-2010 12:52 PM
Create C++ std::locale without changing C locale dertopper@web.de C++ 4 08-26-2008 01:15 PM
Erronous "unsupported locale setting" ? robert Python 3 11-06-2006 08:29 PM
i18n problem, involving Locale.getDisplayLanguage and Locale.getDisplayCountry Maurice Hulsman Java 1 07-25-2004 06:11 PM
locale.nl_langinfo(RADIXCHAR) vs locale.localeconv()['decimal_point'] Jeff Epler Python 2 08-31-2003 02:18 PM



Advertisments