[Python-Dev] deprecating string module?

Skip Montanaro skip@pobox.com
Tue, 28 May 2002 16:34:26 -0500


I know this has been discussed before.  In light of the recent PEP8 update:

    Avoid the use of the string module; instead use string methods.
    These are always much faster and share the same API with unicode
    strings.

I thought I'd raise it again.

How about deprecating the string module?  In the past, this has presented
two major problems.  First, its near ubiquity in Python programs before the
availability of string methods.  Second, the presence of a few useful data
objects (digits, uppercase, etc).  The first problem can be solved by
extending the deprecation time suitably (two years/four releases?)  I think
the second problem can be solved by adding those data objects to either sys
or locale(preferably the latter).  string.letters and its subsets are
locale-dependent.  In relevant locales I presume string.punctuation and
string.whitespace would also be different than their common ASCII elements.

Finally, I'd amend the above PEP8 admontion something like

    Avoid the use of the string module unless backward-compatibility
    with versions earlier than Python 2.0 is important; instead use
    string methods.  These are always much faster and share the same API
    with unicode strings.

Skip