[Tutor] converting unicode

Kent Johnson kent37 at tds.net
Wed Dec 1 11:38:13 CET 2004


Terry Carroll wrote:
>>>>stringtuple = (u'a', u'bcd', u'e')
>>>>''.join(stringtuple)
> 
> u'abcde'
> 
> Interestingly, this is one area where string.join() gets a different 
> result:
> 
> 
>>>>from string import join
>>>>stringtuple = (u'a', u'bcd', u'e')
>>>>join(stringtuple)
 >
 > u'a bcd e'

join(stringtuple, '') is the equivalent to ''.join(stringtuple). If you omit the second argument to 
string.join, it defaults to a single space, not the empty string.

Kent


More information about the Tutor mailing list