[issue33561] Add .tostring() method to xml.etree.ElementTree.Element

Steven Vascellaro report at bugs.python.org
Thu May 17 13:45:56 EDT 2018


Steven Vascellaro <Stevoisiak at gmail.com> added the comment:

Alternatively, the most intuitive solution would be to give `Element` an explicit `__str__` method.

The current behavior of `str(Element)` is to return the object's location in memory.

```
from xml.etree import ElementTree

xml = ElementTree.Element('Person', Name='John')
print(str(xml))
# Output: <Element 'Person' at 0x028575D0>
```

Unfortunately, changing this behavior could cause issues with backwards compatibility.

----------

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


More information about the Python-bugs-list mailing list