[Python-Dev] to string or not to string...

Guido van Rossum guido@python.org
Fri, 24 May 2002 17:20:03 -0400

> Recent checkins mean that:
> E:\CVS\python\dist\src\PCbuild>python
> Python 2.3a0 (#29, May 24 2002, 13:47:58) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> isinstance('foo', string)
> True
>  >>> import string
>  >>> isinstance('foo', string)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: isinstance() arg 2 must be a class or type
>  >>>
> I realize that there isn't a backwards compatibility problem per se, but 
> there is something bothersome about the above, I think.  I also am not 
> to keen on having to keep "str" and "string" separate, but I don't have 
> any better suggestion for the interface name (for that's what "string" is).

'str' and 'string' have to be separate because the whole point is that
isinstance(u"", string) returns True.

We could rename string to basestring?

> Do we want string to be both the module and the interface
> masquerading as a type?

That would *almost* work (string.lower could be an unbound method that
calls the corresponding real class method) except string.join() would
have the arguments reversed. :-(

> [Trent gets the credit for asking the question -- I'm just the tester =)]

Trent needn't be so shy. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)