locale.py strangeness

Torsten Marek shlomme at gmx.net
Sun Jun 8 16:44:25 CEST 2003


Hi list,

I experienced some strange behaviour with locale.py from Python 2.2.3.
The output of the following code snippet

## -- start -- ##

#!/usr/bin/env python
import os
import locale

pa = "ön"
pb = "oo"
locale.setlocale(locale.LC_ALL, "")
print locale.strcoll(pa, pb)
locale.setlocale(locale.LC_ALL, os.getenv("LANG"))
print locale.strcoll(pa, pb)

## -- end -- ##

is

135
-1

but according to the documentation of locale.getdefaultlocale, the 
results should be the same. My locale setting (in "LANG") is 
"de_DE at euro" (which is not support in Python earlier than 2.2.3), and if 
I run
locale.setlocale(locale.LC_ALL, locale.getdefaultlocale())
, a locale.Error is thrown. Can somebody verify this behaviour and give 
some hints about that?

TIA

Torsten





More information about the Python-list mailing list