473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Python Locales under windows

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 ñÑ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ' 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

Jul 18 '05 #1
1 3284
>>> print "%.2f" % 1024.36 # should be '1024,36' 1024.36
[Linux/ Python-2.3.1]
well this doesnt work under Linux neither, you need to use:

locale.format( "%.2f", 1024.36)

after setting the locale
>>> string.letters #should be 54 letters here, including ñÑ

'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ'


Its the same here even afer locale was set, but maybe thats because my Linux
locale is mk_MK.UTF8

I'm using python 2.3 under Windows XP and 2K.


There is "locale.windows_locale" that may help you, although I don't
knowwhat this dictionary is about.

--
Дамјан (jabberID:da****@bagra.net.mk)

There's no place like ~
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the first alpha of Python 2.4. Python 2.4a1 is an alpha release. We'd greatly appreciate it if you could...
0
by: Diez B. Roggisch | last post by:
QOTW: "If I wanted to write five lines instead of one everywhere in a Python program, I'd use Java." -- Paul Rubin http://groups.google.com/group/comp.lang.python/msg/6fac4f3022acd1fa?hl=de& "i...
3
by: Joshua Stewart | last post by:
Hi, I am trying to characterise a problem I am seeing on our C#/C++ xml driven application. We have recently added some basic Spanish language support to our application, but it seems that there...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 349 open ( +7) / 3737 closed (+25) / 4086 total (+32) Bugs : 939 open (-12) / 6648 closed (+60) / 7587 total (+48) RFE : 249 open...
4
by: Gilles Ganault | last post by:
Hello What does it take to support locales? The following test code found on the PHP site doesn't work as planned: ======= setlocale(LC_TIME, "C"); echo strftime("%A"); setlocale(LC_TIME,...
9
by: Larry Hale | last post by:
I've heard tell of a Python binding for libmagic (file(1) *nixy command; see http://darwinsys.com/file/). Generally, has anybody built this and worked with it under Windows? The only thing I've...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.