[issue21028] ElementTree objects should support all the same methods as Element objects

Stefan Behnel report at bugs.python.org
Wed Apr 2 08:02:00 CEST 2014


Stefan Behnel added the comment:

> Add all the element methods to the elementtree object.

Ok, but why? An ElementTree object *is not* an Element. It's a
representation of a document that *has* a root Element.

It makes sense for a document to allow searches over its content, and the
ElementTree class currently supports that, using the find*() or iter()
methods. They are "deep" or "global" content accessor shortcuts, in
addition to the path through the normal getroot() method.

But I can't see how making ElementTree objects look and behave like their
own root Element improves anything. Instead, it would just make the
distinction between the two completely unclear, and would also lead to
quirks like the question why iterating over a document yields the second
level of children. Or the question what the "attrib" property of a document
could mean.

Instead of blurring it, would you have an idea what we could improve in the
documentation to make this distinction clearer?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21028>
_______________________________________


More information about the Python-bugs-list mailing list