ElementTree: How to return only unicode?

Stefan Behnel stefan_ml at behnel.de
Sat Mar 14 22:57:57 CET 2009


Torsten Bronger wrote:
> I parse an XML file with ElementTree and get the contets with
> the .attrib, .text, .get etc methods of the tree's nodes.
> Additionally, I use the "find" and "findtext" methods.
> 
> My problem is that if there is only ASCII, these methods return
> ordinary strings instead of unicode.  So sometimes I get str,
> sometimes I get unicode.  Can one change this globally so that they
> only return unicode?

That's a convenience measure to reduce memory and processing overhead.
Could you explain why this is a problem for you?

Stefan



More information about the Python-list mailing list