string module
Fernando Pérez
fperez528 at yahoo.com
Mon May 20 16:03:33 EDT 2002
Fredrik Lundh wrote:
>> Why the difference?
>
> the readline library might be messing up the locale.
Indeed! Thanks for the information, I was really puzzled. Here's what happens:
[~/test]> python
Python 2.2 (#1, Feb 24 2002, 16:21:58)
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386
Type "help", "copyright", "credits" or "license" for more information.
>>> import string,locale
>>> print string.__file__
/usr/lib/python2.2/string.pyc
>>> print locale.getlocale()
['en_US', 'ISO8859-1']
>>> print string.uppercase
ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ
The strings.py file contains the same above statements:
[~/test]> python strings.py
/usr/lib/python2.2/string.pyc
(None, None)
ABCDEFGHIJKLMNOPQRSTUVWXYZ
So indeed, since I'm loading readline at the interactive prompt, there's an
under the hood resetting of the locale. Ah, the beauty of perl-like silent,
implicit global changes ;)
Thanks for the clarification!
f.
More information about the Python-list
mailing list