String.join revisited (URGENT for 1.6)

Martijn Faassen m.faassen at vet.uu.nl
Wed May 31 08:53:43 EDT 2000


Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
> Johann Hibschman wrote:
>> 
>> Actually, it sounds more and more to me like 'join' should just be
>> left as a function, and not made a method at all.

> Indeed - there seem to be just as many subjective arguments
> in favour of any of the alternatives, so the safest thing
> to do is leave the darn thing alone!

> I know we're promised that string.join will still be there,
> but if ''.join exists, people will start using it, and it
> won't be long before it's unremovable. Too Many Ways To Do It...

Agreed. So keeping string.join() would seem to be the best alternative,
definitely (or possibly making this a builtin, so you don't have
to import to use it, making it import-equivalent with the new .split()).

a = "foo bar baz"  
b = a.split(" ")
assert a == sjoin(b, " ")

versus:

a = "foo bar baz"
b = a.split(" ")
assert a == " ".join(b)

Perhaps we should've left 'split' alone too. :)

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list