Hi Steve, Steve Howe wrote:
Wednesday, May 10, 2006, 6:39:29 AM, you wrote:
simply calling unicode() on XML nodes and ElementTrees. It behaves just like tostring(), but always returns Python unicode strings:
el = etree.Element("test") unicode(el) u'<test/>'
As usual: any comments appreciated.
Shouldn't this be implemented as etree.tounicode() or something like that instead ? This will be more intuitive since there is the tostring() method. And since str(root) will return something like "'<Element a at 8413144>'", I would also expect unicode(root) to behave like that.
Actually, I had first implemented it as "etree.tounicode()" and then switched to plain "unicode()" as I thought /that/ would be more intuitive... Note that _XSLTResultTree already supports str() and now also supports unicode() for the same thing (but unicode). I may let myself get convinced that this is different, though. I'm not sure which is better. Maybe "tounicode()" really prevents people from thinking it should behave as str() - as you do. It's trivial to change, but let me wait to see if other people have similar feelings on this. So, don't consider this feature stable for now. Stefan