summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-15 15:42:31 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-15 15:42:31 (GMT)
commit8d2ef875ec70bd7434f7fdfddfff06b4144408f2 (patch)
treec8d2476f0db022c4d78841a787d1381a7de0da94 /Doc/library
parent00bc0e0a2d0b6c403a3c6ab96fa7d3398b5c751e (diff)
downloadcpython-8d2ef875ec70bd7434f7fdfddfff06b4144408f2.zip
cpython-8d2ef875ec70bd7434f7fdfddfff06b4144408f2.tar.gz
cpython-8d2ef875ec70bd7434f7fdfddfff06b4144408f2.tar.bz2
Update what the locale module documents about string operations.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/locale.rst19
1 files changed, 8 insertions, 11 deletions
diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst
index 630833a..6cfe025 100644
--- a/Doc/library/locale.rst
+++ b/Doc/library/locale.rst
@@ -498,26 +498,23 @@ is almost as bad: it is expensive and affects other threads that happen to run
before the settings have been restored.
If, when coding a module for general use, you need a locale independent version
-of an operation that is affected by the locale (such as :func:`string.lower`, or
+of an operation that is affected by the locale (such as
certain formats used with :func:`time.strftime`), you will have to find a way to
do it without using the standard library routine. Even better is convincing
yourself that using locale settings is okay. Only as a last resort should you
document that your module is not compatible with non-\ ``C`` locale settings.
-.. index:: module: string
-
-The case conversion functions in the :mod:`string` module are affected by the
-locale settings. When a call to the :func:`setlocale` function changes the
-:const:`LC_CTYPE` settings, the variables ``string.lowercase``,
-``string.uppercase`` and ``string.letters`` are recalculated. Note that code
-that uses these variable through ':keyword:`from` ... :keyword:`import` ...',
-e.g. ``from string import letters``, is not affected by subsequent
-:func:`setlocale` calls.
-
The only way to perform numeric operations according to the locale is to use the
special functions defined by this module: :func:`atof`, :func:`atoi`,
:func:`format`, :func:`str`.
+There is no way to perform case conversions and character classifications
+according to the locale. For (Unicode) text strings these are done according
+to the character value only, while for byte strings, the conversions and
+classifications are done according to the ASCII value of the byte, and bytes
+whose high bit is set (i.e., non-ASCII bytes) are never converted or considered
+part of a character class such as letter or whitespace.
+
.. _embedding-locale: