[Python-Dev] reflections on basestring -- and other abstract basetypes

Alex Martelli aleaxit at yahoo.com
Tue Nov 4 05:06:19 EST 2003


On Monday 03 November 2003 06:43 pm, Guido van Rossum wrote:
> > 1. Shouldn't class UserString.UserString inherit from basestring?
> >    After all, basestring exists specifically in order to encourage
> >    typetests of the form isinstance(x, basestring) -- wouldn't it be
> >    better if such tests could also catch "user-tweaked strings"
> >    derived from UserString ... ?
>
> I wish I had time for this thread today, but it doesn't look like it.
> I just wish to express that we shouldn't lightly mess with this.   I

Aye aye cap'n -- we'll just be squabbling and NOT messing until your
say-so, anyway;-).

> added basestr specifically to support some code that was interested in
> testing whether something was one of the *builtin* string types (or a
> subclass thereof).  But I don't recall details and won't be able to
> dig them up today.

basestring usage has become rather widespread today, anyway; the
specific reason it was introduced is interesting to know, but looking at
how it's used e.g. in the std lib is probably more meaningful.

Of course, we always look at string-ish things with more interest
because we use SO many of them, of all kinds, in Python itself
and its stdlib.  But -- numbers may be very important too, to some
subset of Python's users... _and_ in a secondary sense to Python
itself in some cases.


Alex




More information about the Python-Dev mailing list