Issue935749
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2004-04-15 16:26 by quiver, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (2) | |||
---|---|---|---|
msg20513 - (view) | Author: George Yoshida (quiver) | Date: 2004-04-15 16:26 | |
Some string methods/constants are locale dependent, but unlike string constants, string methods lack the description about the locale dependency. This wasn't a big problem in older Python, but since Python 2.3 each time when you start up an IDLE, lib/idlelib/IOBinding.py sets the locale to LC_CTYPE: locale.setlocale(locale.LC_CTYPE, "") This affects the behavior of string methods and module (at least on Windows when locale is set to ('Japanese_Japan', 'cp932')). Here is the result of locale-dependent constants/methods. IDLE 1.0.2 # IDLE on Windows 2000 >>> import string, locale >>> string.letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1 \xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9 \xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6 \xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3 \xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf' >>> _[-1].isalpha() True >>> locale.getlocale() ['Japanese_Japan', '932'] This *feature* can be easily reproduced from the command line. Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import string, locale >>> string.letters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV WXYZ' >>> locale.getlocale() (None, None) >>> locale.setlocale(locale.LC_CTYPE, '') 'Japanese_Japan.932' >>> string.letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1 \xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9 \xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6 \xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3 \xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf' >>> _[-1].isalnum() True Quote from msdn.microsoft.com: * http://msdn.microsoft.com/library/en- us/vclib/html/_crt_isalpha.2c_.iswalpha.asp The result of the test condition for the isalpha function depends on the LC_CTYPE category setting of the current locale; see setlocale for more information. string methods affected are: * isalpha * isalpnum MS also says that some other string methods(islower, isdigit, etc.) are locale dependent, so it might be betterto add a note about the dependency to those methods too. Thanks. |
|||
msg20514 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2004-06-03 09:49 | |
Logged In: YES user_id=21627 Thanks for the report. This list of locale-dependent methods is actually longer; they are now correctly listed in libstdtypes.tex 1.155 and 1.129.8.10. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:03 | admin | set | github: 40154 |
2004-04-15 16:26:34 | quiver | create |