locale.setlocale problems

"Martin v. Löwis" martin at v.loewis.de
Sat Oct 2 11:54:00 CEST 2004


Ksenia Marasanova wrote:
> 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.

Yes. OS X, unfortunately, doesn't really support the C locale APIs.
More precisely, it supports the functions, but they have no meaningful
effect. Python relies on the operating system here, so please bring
this up with your OS vendor.

> 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')

Likewise. Apparently, the operating system does not support that locale,
so Python cannot support it, either.

> 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?

On freebsd4, this may help, but you would need to ask in a FreeBSD
newsgroup. On OS X, you just have to wait a couple more OS releases.

> And the last question: when I change locale in a Python application, it 
> affects only the current namespace, right? I hope so... :)

Not sure what a namespace is, in this context, but I guess the answer is
"yes".

Regards,
Martin



More information about the Python-list mailing list