[Tutor] Using join instead of string.joinfield

Harper, Gina gharper at medplus.com
Tue Aug 23 17:10:04 CEST 2005


Easy.  
Suppose you want to join a list of words with hyphens.
>>> a_list = ['this', 'is', 'a', 'list', 'of', 'words']
>>> sep_char = '-'
>>> print sep_char.join(a_list)
this-is-a-list-of-words
>>> 
*g*
-----Original Message-----
From: Bernard Lebel [mailto:3dbernard at gmail.com] 
Sent: Tuesday, August 23, 2005 11:04 AM
To: Python Tutor list
Subject: [Tutor] Using join instead of string.joinfield


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?


Thanks
Bernard
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list