[Python-Dev] Death to string functions!

Tim Peters tim.one@home.com
Mon, 18 Dec 2000 15:37:13 -0500


[Guido]
> ...
> If you're saying that we should give users ample time for the
> transition, I'm with you.

Then we're with each other, for suitably large values of "ample" <wink>.

> If you're saying that you think the string module is too prominent to
> ever start deprecating its use, I'm afraid we have a problem.

We may.  Time will tell.  It needs a conversion tool, else I think it's
unsellable.

> ...
> I'd also like to note that using the string module's wrappers incurs
> the overhead of a Python function call -- using string methods is
> faster.
>
> Finally, I like the look of fields[i].strip().lower() much better than
> that of string.lower(string.strip(fields[i])) -- an actual example
> from mimetools.py.

I happen to like string methods better myself; I don't think that's at issue
(except that loads of people apparently don't like "join" as a string
method -- idiots <wink>).

The issue to me is purely breaking old code someday -- "string" is in very
heavy use, and unlike as when deprecating regex in favor of re (either pre
or especially sre), string methods aren't orders of magnitude better than
the old way; and also unlike regex-vs-re it's not the case that the string
module has become unmaintainable (to the contrary, string.py has become
trivial).  IOW, this one would be unprecedented fiddling.

> ...
> Note that I believe Java makes a useful distinction that PEP 5 misses:
> it defines both deprecated features and obsolete features.
> *Deprecated* features are simply features for which a better
> alternative exists.  *Obsolete* features are features that are only
> being kept around for backwards compatibility.  Deprecated features
> may also be (and usually are) *obsolescent*, meaning they will become
> obsolete in the future.

I agree it would be useful to define these terms, although those particular
definitions appear to be missing the most important point from the user's
POV (not a one says "going away someday").  A Google search on "java
obsolete obsolescent deprecated" doesn't turn up anything useful, so I doubt
the usages you have in mind come from Java (it has "deprecated", but doesn't
appear to have any well-defined meaning for the others).

In keeping with the religious nature of the battle-- and religion offers
precise terms for degrees of damnation! --I suggest:

    struggling -- a supported feature; the initial state of
        all features; may transition to Anathematized

    anathematized -- this feature is now cursed, but is supported;
        may transition to Condemned or Struggling; intimacy with
        Anathematized features is perilous

    condemned -- a feature scheduled for crucifixion; may transition
        to Crucified, Anathematized (this transition is called "a pardon"),
        or Struggling (this transition is called "a miracle"); intimacy
        with Condemned features is suicidal

    crucified -- a feature that is no longer supported; may transition
        to Resurrected

    resurrected -- a once-Crucified feature that is again supported;
        may transition to Condemned, Anathematized or Struggling;
        although since Resurrection is a state of grace, there may be
        no point in human time at which a feature is identifiably
        Resurrected (i.e., it may *appear*, to the unenlightened, that
        a feature moved directly from Crucified to Anathematized or
        Struggling or Condemned -- although saying so out loud is heresy).