[Python-Dev] String methods... finally
Guido van Rossum
guido at CNRI.Reston.VA.US
Fri Jun 11 07:16:29 CEST 1999
> On Fri, 11 Jun 1999, Skip Montanaro wrote:
> > It occurred to me just a few minutes after sending my previous message that
> > it might make sense to make string.join a method for lists and tuples.
> > They'd obviously have to make the same type checks that string.join does.
> as in:
> >>> ['spam!', 'eggs!'].join()
> 'spam! eggs!'
Note that this is not as powerful as string.join(); the latter works
on any sequence, not just on lists and tuples. (Though that may not
be a big deal.)
I also find it slightly objectionable that this is a general list
method but only works if the list contains only strings; Dave Ascher's
generalization to reduce() is cute but strikes me are more general
than useful, and the name will forever present a mystery to most
Perhaps join() ought to be a built-in function?
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev