From the documentation for the string module at:
C:\Python23\Doc \Python-Docs-2.3.1\lib\modul e-string.html
[quote]
letters: The concatenation of the strings lowercase and uppercase described
below. The specific value is locale-dependent, and will be updated when
locale.setlocal e() is called.
[end quote]
If uch is a unicode character, the operation
uch in string.letters
may (will?) fail in Python 2.3. I've never seen it fail in previous
versions. Examples:
Python 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)] on
win32
[snip]
IDLE 1.0[color=blue][color=green][color=darkred]
>>> import string
>>> '\xa6' in string.digits[/color][/color][/color]
False[color=blue][color=green][color=darkred]
>>> '\xa6' in string.letters[/color][/color][/color]
False[color=blue][color=green][color=darkred]
>>> u'\xa6' in string.letters[/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#3 >", line 1, in -toplevel-
u'\xa6' in string.letters
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0x83 in position 52:
ordinal not in range(128)[color=blue][color=green][color=darkred]
>>>u'\xa6' in string.ascii_le tters[/color][/color][/color]
False[color=blue][color=green][color=darkred]
>>> u'a' in string.letters[/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#1 >", line 1, in -toplevel-
u'a' in string.letters
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0x83 in position 52:
ordinal not in range(128)
Questions:
1. Is this a bug, or am I missing something?
2. Is this an issue only with Idle? I think not completely: this kind of
code seems to work for my app on XP, and not for some of my app's users on
Linux.
3. Is replacing string.letters by string.ascii_le tters the recommended
workaround?
Edward
P.S.
[color=blue][color=green][color=darkred]
>>> string.letters[/color][/color][/color]
'ABCDEFGHIJKLMN OPQRSTUVWXYZabc defghijklmnopqr stuvwxyz\x83\x8 a\x8c\x8e\x9a\x 9
c\x9e\x9f\xaa\x b5\xba\xc0\xc1\ xc2\xc3\xc4\xc5 \xc6\xc7\xc8\xc 9\xca\xcb\xcc\x c
d\xce\xcf\xd0\x d1\xd2\xd3\xd4\ xd5\xd6\xd8\xd9 \xda\xdb\xdc\xd d\xde\xdf\xe0\x e
1\xe2\xe3\xe4\x e5\xe6\xe7\xe8\ xe9\xea\xeb\xec \xed\xee\xef\xf 0\xf1\xf2\xf3\x f
4\xf5\xf6\xf8\x f9\xfa\xfb\xfc\ xfd\xfe\xff'
EKR
--------------------------------------------------------------------
Edward K. Ream email: edreamleo@chart er.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
C:\Python23\Doc \Python-Docs-2.3.1\lib\modul e-string.html
[quote]
letters: The concatenation of the strings lowercase and uppercase described
below. The specific value is locale-dependent, and will be updated when
locale.setlocal e() is called.
[end quote]
If uch is a unicode character, the operation
uch in string.letters
may (will?) fail in Python 2.3. I've never seen it fail in previous
versions. Examples:
Python 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)] on
win32
[snip]
IDLE 1.0[color=blue][color=green][color=darkred]
>>> import string
>>> '\xa6' in string.digits[/color][/color][/color]
False[color=blue][color=green][color=darkred]
>>> '\xa6' in string.letters[/color][/color][/color]
False[color=blue][color=green][color=darkred]
>>> u'\xa6' in string.letters[/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#3 >", line 1, in -toplevel-
u'\xa6' in string.letters
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0x83 in position 52:
ordinal not in range(128)[color=blue][color=green][color=darkred]
>>>u'\xa6' in string.ascii_le tters[/color][/color][/color]
False[color=blue][color=green][color=darkred]
>>> u'a' in string.letters[/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#1 >", line 1, in -toplevel-
u'a' in string.letters
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0x83 in position 52:
ordinal not in range(128)
Questions:
1. Is this a bug, or am I missing something?
2. Is this an issue only with Idle? I think not completely: this kind of
code seems to work for my app on XP, and not for some of my app's users on
Linux.
3. Is replacing string.letters by string.ascii_le tters the recommended
workaround?
Edward
P.S.
[color=blue][color=green][color=darkred]
>>> string.letters[/color][/color][/color]
'ABCDEFGHIJKLMN OPQRSTUVWXYZabc defghijklmnopqr stuvwxyz\x83\x8 a\x8c\x8e\x9a\x 9
c\x9e\x9f\xaa\x b5\xba\xc0\xc1\ xc2\xc3\xc4\xc5 \xc6\xc7\xc8\xc 9\xca\xcb\xcc\x c
d\xce\xcf\xd0\x d1\xd2\xd3\xd4\ xd5\xd6\xd8\xd9 \xda\xdb\xdc\xd d\xde\xdf\xe0\x e
1\xe2\xe3\xe4\x e5\xe6\xe7\xe8\ xe9\xea\xeb\xec \xed\xee\xef\xf 0\xf1\xf2\xf3\x f
4\xf5\xf6\xf8\x f9\xfa\xfb\xfc\ xfd\xfe\xff'
EKR
--------------------------------------------------------------------
Edward K. Ream email: edreamleo@chart er.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Comment