Re: Rev() with better repr [and complaint about pedantic typechecking]

Guido.van.Rossum@cwi.nl
Fri, 29 Oct 1993 11:31:58 +0100

> But it WOULD be nice if string and sequence functions worked for
> pseudo-strings and pseudo-sequence object classes. For example -
> if I actually wrote a mutable string class, I would expect
> string.split to work on it. ( strop.split won't. )

Well it is possible in most cases to write Python code to work
irrespective of the actual sequence type used. It takes a little
care, e.g. you must use a[:0] (where a is the argument of unknown
sequence type) instead of an empty value of a specific type.

I don't know if all the code in string.py is correct in this respect;
I suspect not, but most of it will be okay -- on the other hand it is
only intended to work on strings so who cares. I suppose an
appropriate subset of the routines from string.py could be provided as
sequence.py (totally avoiding the "from strop import *" issue).

On the other hand, as I wrote in my previous mail, fixing strop and
other built-in modules to have the same kind of genericity would be
difficult. Strop was designed to implement string manipulations as
fast as possible by exploiting the C representation; perhaps a seqop
module could be written which does somilar things for generic
sequences.

Any volunteers?

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>