[Python-Dev] join() et al.

M.-A. Lemburg mal at lemburg.com
Mon May 15 17:50:39 EDT 2000

"Barry A. Warsaw" wrote:
> >>>>> "CT" == Christian Tismer <tismer at tismer.com> writes:
>     CT> If it came to the point where the string module had some extra
>     CT> methods which operate on two lists of string perhaps, we would
>     CT> have been totally lost, and enforcing some OO method to
>     CT> support it would be completely off the road.
> The new .join() method reads a bit better if you first name the
> glue string:
> space = ' '
> name = space.join(['Barry', 'Aloisius', 'Warsaw'])
> But yes, it does look odd when used like
> ' '.join(['Christian', 'Aloisius', 'Tismer'])
> I still think it's nice not to have to import string "just" to get the
> join functionality, but remember of course that string.join() isn't
> going away, so you can still use this if you like it better.

string.py is depreciated, AFAIK (not that it'll go away anytime
soon, but using string method directly is really the better,
more readable and faster approach).
> Alternatively, there has been talk about moving join() into the
> built-ins, but I'm not sure if the semantics of tha have been nailed
> down.

This is probably the way to go. Semantics should probably

	join(seq,sep) := reduce(lambda x,y: x + sep + y, seq)

and should work with any type providing addition or
concat slot methods.

Patches anyone ?

Marc-Andre Lemburg
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/

More information about the Python-list mailing list