Python parsing iTunes XML/COM

william tanksley wtanksleyjr at gmail.com
Fri Aug 1 20:02:40 EDT 2008


John Machin <sjmac... at lexicon.net> wrote:
> william tanksley <wtanksle... at gmail.com> wrote:

> > Cool. Sorry for the misunderstanding. Thank you for helping again!
> > Postscript: your request to print the actual data did the trick.
> I'd back inspecting actual data against armchair philosophy any
> time :-)

Heh. It's a recurring problem with me, to tell the truth.

> > You're right that single quotes are expected -- and I'd expect a
> > preceding u, since they're supposed to be Unicode. I dunno what's
> > going on.

> Why do you suppose that the contents are Unicode? It's a URL-encoded
> string i.e. *deliberately* ASCII, in fact sub-ASCII (see all the %20
> stuff?). What's going on is that ElementTree presents text as ASCII if
> it can be so represented, otherwise as Unicode. This is actually a
> *convenience*. Get used to it. Enjoy it.

This isn't what caused the problem, but how is it convenient to get
Unicode sometimes and ASCII other times? Given that the input file was
Unicode, and in fact some of the values required Unicode, I'd expect
to have gotten Unicode out for everything.

I don't see how it matters; as far as I know, the methods available
for Unicode and ASCII strings are the same, and only the type() is
different. So I'm not saying it's a problem; I'm just not seeing how
it's a _convenience_.

> > So all of the mysteries are solved (except for my Python's
> > doublequotes, but who cares), and ElementTree is entirely vindicated.

> Shucks. I can sense that you'd been looking forward to conducting an
> auto-da-fe followed by tossing the author on a bonfire ... but you
> can't burn a bot anyway :-)

Well, I really _was_ expecting the Spanish Inquisition. Darn.

-Wm



More information about the Python-list mailing list