[Python-Dev] String methods... finally

Fredrik Lundh fredrik at pythonware.com
Fri Jun 11 09:06:58 CEST 1999

Guido wrote: 
> 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
> newcomers.
> Perhaps join() ought to be a built-in function?

come to think of it, the last design I came up with (inspired
by a mail from you which I cannot find right now), was this:

def join(sequence, sep=None):
    # built-in
    if not sequence:
        return ""
    sequence[0].__join__(sequence, sep)

string.join => join

and __join__ methods in the unicode and string classes.



More information about the Python-Dev mailing list