locale.setlocale problems

Ksenia Marasanova ksenia at ksenia.nl
Sat Oct 2 04:33:39 EDT 2004


Hi,

I have some problems with locale module.
On my workstation, changing locale doesn't have effect:

Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import locale
 >>> locale.setlocale(locale.LC_ALL, 'nl_NL')
'nl_NL'
 >>> locale.format('%0.2f', 0.123)
'0.12'

(It should return: 0,12)


On the server, it doesn't work at all:

Python 2.3 (#1, Jan  4 2004, 14:30:19)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
 >>> import locale
 >>> locale.setlocale(locale.LC_ALL, 'nl_NL')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/local/lib/python2.3/locale.py", line 381, in setlocale
     return _setlocale(category, locale)
locale.Error: locale setting not supported

All I want to do, is format numbers with comma as decimal separator in 
a web application. Is there some system libraries I have to install, to 
make locale work?
And the last question: when I change locale in a Python application, it 
affects only the current namespace, right? I hope so... :)

Thanks!
Ksenia.




More information about the Python-list mailing list