string goes away

Duncan Booth duncan.booth at invalid.invalid
Fri Apr 1 03:20:33 EST 2005


Andreas Beyer wrote:

> I loved to use
> >>> string.join(list_of_str, sep)
> instead of
> >>> sep.join(list_of_str)
> 
> I think the former is much more telling what is happening than the 
> latter. However, I will get used to it.

No need to get used to it. Just reverse the order of the arguments and use:

   str.join(sep, list_of_str)

Alternatively it can be clearer if you bind a name to the bound method:

   joinLines = '\n'.join
   joinWords = ' '.join

   lines = joinLines(somelines)
   words = joinWords(somewords)



More information about the Python-list mailing list