[Python-Dev] Iterable String Redux (aka String ABC) (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Jun 1 12:54:15 CEST 2008


Armin Ronacher wrote:

basestring is not subclassable for example. Also it requires subclassing which ABCs do not.

The use case that was cited was recognising subclasses of UserString, and that's what I was responding to. If basestring were made subclassable and UserString inherited from it, that use case would be covered.

Recognising string-like objects without requiring subclassing is a hopeless morass to get into, in my opinion. You'll just have endless arguments about which of the zillion methods of str should be in the blessed set which confers string-ness.

I also think that the ABC idea in general suffers from that problem, to one degree or another depending on the class involved. Strings are just an extreme case.

-- Greg



More information about the Python-Dev mailing list