locale.setlocale problems
hyeshik at gmail.com
hyeshik at gmail.com
Sun Oct 3 13:51:18 EDT 2004
On Sat, 02 Oct 2004 11:26:47 +0200, Ksenia Marasanova <ksenia at ksenia.nl> wrote:
> 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
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.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'nl_NL.ISO8859-1')
'nl_NL.ISO8859-1'
>>> locale.format('%0.2f', 0.123)
'0,12'
>
> > 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.
There's a mailing list "python at FreeBSD.org" for this purpose.
You can subscribe the list at
http://lists.freebsd.org/mailman/listinfo/freebsd-python
>
> >> 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".
>
> 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
More information about the Python-list
mailing list