473,394 Members | 1,714 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,394 software developers and data experts.

locale.getlocale() strange behaviour

here are my locales
benoit@athlon >> locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=fr_FR.UTF-8

(full utf-8 system)
python2.3 -c 'import locale; print locale.getlocale()' (None, None)
python2.2 -c 'import locale; print locale.getlocale()' (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.getlocale() (None, None)

python2.2

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.getlocale()

['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 3308
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
en_US.UTF-8
$ python -c 'import locale; print locale.getlocale()'
(None, None)
$ python -c 'import locale; locale.setlocale(locale.LC_ALL, ""); print locale.getlocale()'
['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.getlocale()'
['en_US', 'utf']
this may explain the behavior you noticed.

Jeff

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.getlocale()'
['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

0
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 =...
2
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,...
0
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...
3
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...
7
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...
2
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...
2
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') É
2
by: year1943 | last post by:
There was the same topic not so long ago, but as I see it stays w/o answer:...
24
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
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...
0
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...

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.