[Tutor] Using join instead of string.joinfield

Kent Johnson kent37 at tds.net
Tue Aug 23 17:18:20 CEST 2005


Bernard Lebel wrote:
> Hello,
> 
> The documentation says that the built-in join method now replaces the
> string.joinfield function.  However how do you achieve the same
> operation? The join method accepts only one argument, that is, the
> list of strings to join. How do you then specify the separating
> character?

join() is a method of a string object. The string you invoke it on is the separating character. It may seem a bit strange but it works:

 >>> l=['hello', 'world', 'how are you?']
 >>> ', '.join(l)
'hello, world, how are you?'

Kent



More information about the Tutor mailing list