
Stefan Behnel wrote: [snip]
str() is called on the result, not on the XSLT object here.
A better way of doing this would be to return a subclass of _ElementTree (_XSLTResultTree?) that would then have a __str__ method. We would just have to splitting up the ElementTree factory.
I think that would be the right thing to do, since it would also prevent calling XSLT.tostring() with a non XSLT-generated _ElementTree object. Actually, if we go for __str__, we should even depricate XSLT.tostring(), as it is much more pythonic to just call str() on the result.
BTW: What about putting another __str__ into _ElementTree and having it return the unindented UTF-8 serialization of the tree?
Basically the proposal would be: * the ElementTree API gains a __str__() * we have a special subclass of ElementTree for the result returned by XSLT transformation, which implements its own __str__() that does the XSLT.tostring(). This sounds interesting. I wonder whether the first point, adding a __str__(), would also make sense for ElementTree proper? Regards, Martijn