This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: In xml.etree.ElementTree docs there are many absent Element class links
Type: behavior Stage: patch review
Components: Documentation, Library (Lib), XML Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eli.bendersky, martin.panter, py.user, scoder, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-09-21 10:27 by py.user, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
element-link.diff py.user, 2016-09-21 10:27 Add Element links review
Pull Requests
URL Status Linked Edit
PR 9766 serhiy.storchaka, 2018-10-09 14:05
Messages (8)
msg277121 - (view) Author: py.user (py.user) * Date: 2016-09-21 10:27
https://docs.python.org/3/library/xml.etree.elementtree.html#reference

1. Comment
2. iselement()
3. ProcessingInstruction
4. SubElement
5. Element.find()
6. ElementTree._setroot()
7. TreeBuilder

Applied a patch to the issue that adds Element class links.
msg277187 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-09-22 01:37
Mostly looks good to me. I left some comments on the code review.
msg277194 - (view) Author: py.user (py.user) * Date: 2016-09-22 06:11
> I left some comments on the code review.
Left an answer on a comment. (ISTM, email notification doesn't work there, I didn't get email.)
msg277197 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-22 06:26
In lxml Element is a factory function, not a class.
msg277209 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-09-22 08:39
Serhiy, what’s the relevance? In the built-in Element Tree package, it is a class: <https://docs.python.org/3.5/library/xml.etree.elementtree.html#element-objects>.
msg277211 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-22 09:02
The built-in ElementTree package is derived from lxml.etree. I suppose that the documentation is inherited from lxml.etree.

The built-in ElementTree package supports duck typing. The element object is not always an instance of the Element class. iselement() is not equal to isinstance(e, Element), it just tests the existence of the tag attribute. Many ElementTree functions have fast path for Element, but work with duck typed classes too. I believe that in particular you can mix Python and C implementations of Element and lxml.etree elements in one tree.
msg277219 - (view) Author: py.user (py.user) * Date: 2016-09-22 11:31
Serhiy Storchaka wrote:
> I believe that in particular you can mix Python and
> C implementations of Element and lxml.etree elements in one tree.


The xml.etree.ElementTree.ElementTree() can accept lxml.etree.Element() as a node, but node in node is impossible.

>>> import xml.etree.ElementTree as etree_xml
>>> import lxml.etree as etree_lxml
>>> 
>>> elem1 = etree_xml.Element('a')
>>> elem2 = etree_lxml.Element('b')
>>> elem1.append(elem2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: must be xml.etree.ElementTree.Element, not lxml.etree._Element
>>>
msg277255 - (view) Author: py.user (py.user) * Date: 2016-09-23 08:47
Added a reply to the patch about SubElement(). (Realy email notification doesn't work in review. I left a message while publication, and it didn't come.)
History
Date User Action Args
2022-04-11 14:58:37adminsetgithub: 72421
2018-10-09 14:05:31serhiy.storchakasetpull_requests: + pull_request9156
2016-09-23 08:47:46py.usersetmessages: + msg277255
2016-09-22 11:31:25py.usersetmessages: + msg277219
2016-09-22 09:02:11serhiy.storchakasetmessages: + msg277211
2016-09-22 08:39:48martin.pantersetmessages: + msg277209
2016-09-22 06:26:38serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg277197
2016-09-22 06:11:29py.usersetmessages: + msg277194
2016-09-22 01:37:36martin.pantersetnosy: + martin.panter

messages: + msg277187
versions: + Python 2.7, Python 3.5, Python 3.7
2016-09-21 16:35:13serhiy.storchakasetnosy: + scoder, eli.bendersky

stage: patch review
2016-09-21 10:27:48py.usercreate