iterparse and unicode

George Sakkis george.sakkis at gmail.com
Tue Aug 26 22:06:45 EDT 2008


On Aug 25, 4:45 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> George Sakkis wrote:
> > It depends on what you mean by "compatible"; e.g. you can't safely do
> > [s.decode('utf8') for s in strings] if you have byte strings mixed
> > with unicode.
>
> why would you want to decode strings given to you by a library that
> returns decoded strings?
>
> if you meant to write "encode", you can indeed safely do
> [s.encode('utf8') for s in strings] as long as all strings are returned
> by an ET implementation.

I was replying to the general assertion that "in 2.x ASCII byte
strings and unicode strings are compatible", not specifically about
the strings returned by ET.

George



More information about the Python-list mailing list