Python parsing iTunes XML/COM

william tanksley wtanksleyjr at gmail.com
Wed Jul 30 20:33:24 EDT 2008


"Jerry Hill" <malaclyp... at gmail.com> wrote:
> On Wed, Jul 30, 2008 at 2:27 PM, william tanksley <wtanksle... at gmail.com> wrote:
> > Awesome... Thank you! I had my mental model of Python turned around
> > backwards. That's an odd feeling. Okay, so you decode to go from raw
> > byes into a given encoding, and you encode to go from a given encoding
> > to raw bytes. Not what I thought it was, but that's cool, makes sense.

> That's not quite right.  Decoding takes a byte string that is already
> in a particular encoding and transforms it to unicode.  Unicode isn't
> a encoding of it's own.  Decoding takes a unicode string (which
> doesn't have any encoding associated with it), and gives you back a
> sequence of bytes in a particular encoding.

Okay, this is useful. Thank you for straightening out my mental model.
It makes sense to define strings as just naturally Unicode... and
anything else is in some ways not really a string, although it's
something that might have many of the same methods. I guess this
mental model is being implemented more thoroughly in Py3K... Anyhow,
it makes sense.

I'm still puzzled why I'm getting some non-Unicode out of an
ElementTree's text, though.

> Jerry

-Wm



More information about the Python-list mailing list