Dan Bishop wrote:
John J. Lee wrote:

Doesn't work with unicode, IIRC.

u" ".join(["What's", "the", "problem?"])

u"What's the problem?"

str.join(x, y) isn't quite a drop-in replacement for string.join(y, x), since it's not polymorphic on the joining string:

>>> str.join(u" ", ["a", "b"])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: descriptor 'join' requires a 'str' object but received a 'unicode'

The strings being joined can be unicode, though:

>>> str.join(" ", [u"a", u"b"])
u'a b'

So it's probably not a serious problem, since in most
cases you'll know whether the joining string is unicode
or not when you write the code. If not, you'll just
have to do it the "new" way.

--
Greg Ewing, Computer Science Dept,
University of Canterbury,       
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to