[issue46798] xml.etree.ElementTree: get() doesn't return default value, always ATTLIST value

Stefan Behnel report at bugs.python.org
Wed Feb 23 06:49:25 EST 2022


Stefan Behnel <stefan_ml at behnel.de> added the comment:

> IMHO if the developer doesn't manage the XML itself it is VERY unreasonable to use the document value and not the developer one.

I disagree. If the document says "this is the default if no explicit value if given", then I consider that just as good as providing a value each time. Meaning, the attribute *is* in fact present, just not explicitly spelled out on the element.

I would specifically like to avoid adding a new option just to override the way the document distributes its attribute value spelling across DTD and document structure. In particular, the .get() method is the wrong place to deal with this.

You can probably configure the parser to ignore the internal DTD subset, if that's what you want.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46798>
_______________________________________


More information about the Python-bugs-list mailing list