Python Locales under windows
Moof
moof at metamoof.net
Tue Oct 28 11:47:12 EST 2003
Hi there,
I'm trying to use some country-specific services provided by python
under Windows, and I'm coming up with a couple of problems, specifically
that floats are not being printed correctly when converted to strings
(they print out as 1,024.36 instead of 1.024,36), and also the contents
of \w inside a regexp, which I believe is equivalent to string.letters.
Under linux, I can get around this by setting the locale correctly.
Under windows, I'm buggered if I can work out how:
>>> print "%.2f" % 1024.36 # should be '1024,36'
1024.36
>>> string.letters #should be 54 letters here, including ñÑ
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> locale.getlocale()
(None, None)
>>> locale.getdefaultlocale()
('es_ES', 'cp1252')
>>> locale.setlocale(locale.LC_ALL, locale.getdefaultlocale())
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python23\lib\locale.py", line 381, in setlocale
return _setlocale(category, locale)
Error: locale setting not supported
That's the clincher: I can't seem to set locales. Why is this? IS there
a way to get around this?
I'm using python 2.3 under Windows XP and 2K.
Moof
More information about the Python-list
mailing list