473,851 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

locale.getlocal e() strange behaviour

here are my locales
benoit@athlon >> locale
LC_TIME="fr_FR. UTF-8"
LC_NAME="fr_FR. UTF-8"

(full utf-8 system)
python2.3 -c 'import locale; print locale.getlocal e()' (None, None)
python2.2 -c 'import locale; print locale.getlocal e()' (None, None)
python2.3 Python 2.3.3 (#2, Feb 24 2004, 09:29:20)
[GCC 3.3.3 (Debian)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
import locale
locale.getlocal e() (None, None)


Python 2.2.3+ (#1, Feb 25 2004, 23:29:31)
[GCC 3.3.3 (Debian)] on linux2
Type "help", "copyright" , "credits" or "license" for more information. import locale
locale.getlocal e()

['fr_FR', 'utf']
2.3 fails getting locale
but 2.2 also fails when running inline :/

makes me crazy :D

Jul 18 '05 #1
2 3339
Just as in C programs, the LANG and LC_* environment variables have no
effect until setlocale is called with "" as the second argument.

On my system:
$ echo $LANG
$ python -c 'import locale; print locale.getlocal e()'
(None, None)
$ python -c 'import locale; locale.setlocal e(locale.LC_ALL , ""); print locale.getlocal e()'
['en_US', 'utf']

In Python2.2 on my system, setlocale() is called by rl_initialize() when
I run the interactive interpreter.
$ python -c 'import locale; import readline; print locale.getlocal e()'
['en_US', 'utf']
this may explain the behavior you noticed.


Jul 18 '05 #2
Le Tue, 02 Mar 2004 20:09:26 -0600, Jeff Epler a écrit*:

In Python2.2 on my system, setlocale() is called by rl_initialize() when
I run the interactive interpreter.
$ python -c 'import locale; import readline; print locale.getlocal e()'
['en_US', 'utf']
this may explain the behavior you noticed.

thanks a lot

Jul 18 '05 #3

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

Similar topics

by: Daniele Varrazzo | last post by:
Hi everybody Is there any way to make the most of locale.localeconv() in formatting currencies? I can use many tricks as >>> locale.setlocale(locale.LC_ALL, locale.getlocale()) >>> lc = locale.localeconv() >>> >>> cash = 1427.48 >>> print "%s%s" % (
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
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
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
by: Ralf Goertz | last post by:
Hi, since my previous post <455440ad$0$30326$9b4e6d93@newsspool1.arcor-online.netis still unanswered I'd like to rephrase my question. In order to read/write a wstring in UTF-8 encoding it is *not* sufficient to imbue the stream with a locale like "de_DE.UTF-8". Doing so only takes care of facets of decimal numbers and the like. Rather, one has to call locale::global("de_DE.UTF-8"). Is this behaviour conforming to the standard? And if...
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...
by: Clodoaldo | last post by:
When using unicode the case change works: é But when using the pt_BR.utf-8 locale it doesn't: 'pt_BR.utf-8' ('pt_BR', 'utf') É
by: year1943 | last post by:
There was the same topic not so long ago, but as I see it stays w/o answer: http://groups.google.ru/group/comp.lang.c++/browse_thread/thread/9a05d7bba9394a60/fe109c899f916871?lnk=gst&q=locale+imbue&rnum=1&hl=ru#fe109c899f916871 As Bjarne Stroustrup said in his book, "in Stroustrup (retranslated from German) "Setting the global locale does not affect existing input/output streams. The streams continue to use those locales that were...
by: Donn Ingle | last post by:
Hello, I hope someone can illuminate this situation for me. Here's the nutshell: 1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale. 2. If this returns "C" or anything without 'utf8' in it, then things start to go downhill: 2a. The app assumes unicode objects internally. i.e. Whenever there is
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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...
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...
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...
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();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.