[Python-Dev] locale and LC_NUMERIC

Fredrik Lundh fredrik at pythonware.com
Mon Jan 9 09:54:09 CET 2006


Neal Norwitz wrote:

> > I feel I'm lacking some link here: why do you think we should do that?
>
> neal at janus ~/build/python/svn/clean-ish $ LC_ALL=de_DE ./python
> >>> import locale
> >>> locale.setlocale(locale.LC_ALL)
> 'C'
> >>> locale.setlocale(locale.LC_ALL, 'de_DE')
> 'de_DE'
>
> I would have expected the first call to setlocale() to return de_DE.

the locale is a program-specific setting (handled by the C runtime library),
and is set to "C" by default.

if you want to use a specific locale, you have to call setlocale to indicate
that you really want a non-default locale.  the "" argument is just a con-
venience; it tells the C runtime library to set the locale based on OS-level
language settings (e.g. LANG on Unix, control panel settings on Windows,
etc).

LANG in itself isn't the locale; it's just a way to tell a locale-aware program
what the preferred locale is.

</F>





More information about the Python-Dev mailing list