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

Erik Max Francis max at alcyone.com
Thu May 20 21:36:44 EDT 2004


Jim Hefferon wrote:

> Forgive me, Peter, but you've only rephrased my question: I'm going to
> decode them later, so why does the concatenator insist on decoding
> them now?

Because you're mixing normal strings and Unicode strings.  To do that,
it needs to convert the normal strings to Unicode, and to do that it has
to know what encoding you want.

> As I understand it (perhaps this is my error),
> encoding/decoding is stuff that you do external to manipulating the
> arrays of characters.

It's the process by which you turn an arbitrary string into a Unicode
string and back.  When you're adding normal strings and Unicode strings,
you end up with a Unicode string, which means the normal strings have to
be implicitly converted.  That's why you're getting the error.

Work with strings or Unicode strings, not a mixture, and you won't have
this problem.

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ She glanced at her watch ... It was 9:23.
    -- James Clavell



More information about the Python-list mailing list