473,700 Members | 2,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

locale.setlocal e problems

Hi,

I have some problems with locale module.
On my workstation, changing locale doesn't have effect:

Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
import locale
locale.setlocal e(locale.LC_ALL , 'nl_NL') 'nl_NL' locale.format(' %0.2f', 0.123) '0.12'

(It should return: 0,12)
On the server, it doesn't work at all:

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.setlocal e(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(cate gory, locale)
locale.Error: locale setting not supported

All I want to do, is format numbers with comma as decimal separator in
a web application. Is there some system libraries I have to install, to
make locale work?
And the last question: when I change locale in a Python application, it
affects only the current namespace, right? I hope so... :)

Thanks!
Ksenia.

Jul 18 '05 #1
3 3250
Ksenia Marasanova wrote:
I have some problems with locale module.
On my workstation, changing locale doesn't have effect:

Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
Yes. OS X, unfortunately, doesn't really support the C locale APIs.
More precisely, it supports the functions, but they have no meaningful
effect. Python relies on the operating system here, so please bring
this up with your OS vendor.
On the server, it doesn't work at all:

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.setlocal e(locale.LC_ALL , 'nl_NL')

Likewise. Apparently, the operating system does not support that locale,
so Python cannot support it, either.
All I want to do, is format numbers with comma as decimal separator in a
web application. Is there some system libraries I have to install, to
make locale work?
On freebsd4, this may help, but you would need to ask in a FreeBSD
newsgroup. On OS X, you just have to wait a couple more OS releases.
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".

Regards,
Martin
Jul 18 '05 #2
> 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.
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... :-)

Thank you,
Ksenia.
Jul 18 '05 #3
On Sat, 02 Oct 2004 11:26:47 +0200, Ksenia Marasanova <ks****@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.setlocal e(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(cate gory, 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.setlocal e(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 "py****@FreeBSD .org" for this purpose.
You can subscribe the list at
http://lists.freebsd.org/mailman/lis...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 _CurrentRuneLoc ale). If you change the locale, it affects
all the namespaces/modules/threads but will not affect system
settings or other processes.

Hye-Shik
Jul 18 '05 #4

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

Similar topics

2
1959
by: Jorgen Grahn | last post by:
I'm sitting here with a Debian Linux 'Woody' system with the default Python 2.2 installation, and I want the re module to understand that re.compile(r'\W+'. re.LOCALE) doesn't match my national, accented characters. I don't quite understand how the locale module reasons about these things, and Python doesn't seem to act as other programs on my system. Bug or my mistake? Here's my environment: frailea> env |grep -e LC -e LANG
2
3969
by: Mike Conmackie | last post by:
Greetings, Is there any way to force strftime() to ignore locale settings when formatting the resulting string? I have a requirement to create a specific date-time string format in UTC. gmtime() will populate a struct tm with the correct values but strftime() always assumes that the values are in local time. I could manually adjust the struct tm values so that strftime() would generate the desired string but it gets really ugly when...
3
3531
by: gelbeiche | last post by:
I have a question regarding the following small C program. #include <locale.h> int main() { char* loc = 0; char before,after; int i;
0
1084
by: Manlio Perillo | last post by:
Regards. I have a few questions about locale handling on Windows. The first: why getlocale() returns (None, None) when the locale is 'C'? The second is: why this code fails?: >>> loc, enc = locale.getdefaultlocale() >>> print loc, enc
3
7194
by: robert | last post by:
Why can the default locale not be set by its true name? but only by '' ? : PythonWin 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win32. (None, None) Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Python25\lib\locale.py", line 476, in setlocale return _setlocale(category, locale) Error: unsupported locale setting
2
3637
by: Daniele C. | last post by:
I will report a snippet from http://php.net/setlocale I spent about 2 seconds before thinking: can it really be? I mean, is there no way to set locale info per thread? And after a brief web search I came up with this keyword: _configthreadlocale Read more at http://msdn2.microsoft.com/en-us/library//26c0tb7x(VS.80).aspx (beware, this page is very slow or their servers are anyway). Looks like this function exists since Windows 95 and...
5
3592
by: Sashi Asokarajan | last post by:
Hello, recently I stepped over Strotrup's TC++PL (third ed.) Chapter D.1 where the localization support of the C++ stdlib is explained. http://www.research.att.com/~bs/3rd_loc.pdf ] Unfortunately the constructor fails if I try to instantiate std::locale for locales other than C or POSIX. With (only) LANG="de.DE.UTF-8" set in ENV the following code thows an exception: std::locale loc("");
0
1056
by: Gabriel Genellina | last post by:
En Tue, 26 Aug 2008 07:52:21 -0300, Robert Rawlins <robert.rawlins@thinkbluemedia.co.ukescribi�: Probably you don't have support for 'de_DE' locale. Try using locale.setlocale(locale.LC_ALL, '') and see what you get in response. I'd like to know how to retrieve that too...
0
1182
by: Matthias Huening | last post by:
Hi, I have problems using tkFileDialog under Linux (Ubuntu 8.04 in my case, but other Linuxes seem to show the same behaviour). The following works fine: import tkFileDialog f = tkFileDialog.askopenfilename()
0
9074
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8924
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7807
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5902
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3088
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.