locale.setlocale problems

  • Thread starter Ksenia Marasanova
  • Start date
K

Ksenia Marasanova

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.'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.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.
 
K

Ksenia Marasanova

Python relies on the operating system here, so please bring
this up with your OS vendor.

Okay, I got it now. Thanks for the explanation.
Not sure what a namespace is, in this context, but I guess the answer
is
"yes".

With 'namespace' I meant only the module when the locale is changed, so
it not affects other scripts that run at the same time on the system. I
misunderstood locale as being some system-wide 'registry' which
remembers the changes in it. (have some vague, bad memories about
changing locale in an ASP application... :)

Thank you,
Ksenia.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Ksenia said:
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.

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
 
G

Guest

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

FreeBSD is very strict for locale names. You should write it like this:

Python 2.3.4 (#2, Aug 21 2004, 20:09:51)
[GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
Type "help", "copyright", "credits" or "license" for more information.
'0,12'


Okay, I got it now. Thanks for the explanation.

There's a mailing list "(e-mail address removed)" for this purpose.
You can subscribe the list at
http://lists.freebsd.org/mailman/listinfo/freebsd-python
With 'namespace' I meant only the module when the locale is changed, so
it not affects other scripts that run at the same time on the system. I
misunderstood locale as being some system-wide 'registry' which
remembers the changes in it. (have some vague, bad memories about
changing locale in an ASP application... :)

locale stuff are process-scope variable. (In FreeBSD, global libc
variable _CurrentRuneLocale). If you change the locale, it affects
all the namespaces/modules/threads but will not affect system
settings or other processes.

Hye-Shik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top