iterparse and unicode

Fredrik Lundh fredrik at pythonware.com
Mon Aug 25 16:45:49 EDT 2008


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.

</F>




More information about the Python-list mailing list