Why does the "".join(r) do this?

Peter Hansen peter at engcorp.com
Thu May 20 11:46:14 EDT 2004


Jim Hefferon wrote:

> I'm getting an error join-ing strings and wonder if someone can
> explain why the function is behaving this way?  If I .join in a string
> that contains a high character then I get an ascii codec decoding
> error.  (The code below illustrates.)  Why doesn't it just
> concatenate?

It can't just concatenate because your list contains other
items which are unicode strings.  Python is attempting to convert
your strings to unicode strings to do the join, and it fails
because your strings contain characters which don't have
meaning to the default decoder.

-Peter



More information about the Python-list mailing list