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

Skip Montanaro skip at pobox.com
Thu May 20 11:51:29 EDT 2004


    Jim> I'm building up a web page by stuffing an array and then doing
    Jim> "".join(r) at the end.  I intend to later encode it as 'latin1', so
    Jim> I'd like it to just concatenate.  While I can work around this
    Jim> error, the reason for it escapes me.

Try 

    u"".join(r)

instead.  I think the join operation is trying to convert the Unicode bits
in your list of strings to strings by encoding using the default codec,
which appears to be ASCII.

Skip




More information about the Python-list mailing list