[lxml-dev] is tostring() confusing?
Christian Zagrodnick
cz at gocept.com
Mon Jun 11 08:10:29 CEST 2007
On 2007-06-08 19:09:30 +0200, Ian Bicking <ianb at colorstudy.com> said:
> Having tostring() as a function and not a method seems a bit odd to me.
> I know it's from ElementTree, but at least for HTML it's awkward --
> using lxml.etree.tostring on HTML is almost certain to create bad
> output; the output won't be real XHTML (lacking namespaces and it'll
> probably be invalid), and it will parse quite badly as HTML (<script
> src="..."/> for instance will typically break the entire page in a
> browser).
>
> When I was first using ElementTree, I remember being a bit baffled by
> the lack of a serializing method. I then found tostring and kind of
> forgot about it, but as I copy tostring methods around (e.g.,
> lxml.html.tostring) it's starting to seem like a problem again.
What I wonder about is, why str(tree) or unicode(tree) isn't
supported. I see that str/unicode cannot have arguments (i.e.
pretty-print, encoding). But still there are suitable defaults, are
there not.
Regards
--
Christian Zagrodnick
gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale
www.gocept.com · fon. +49 345 12298894 · fax. +49 345 12298891
More information about the lxml-dev
mailing list