Author martin.panter
Recipients docs@python, eli.bendersky, jlaurens, martin.panter, ned.deily, rhettinger, scoder
Date 2015-05-13.04:06:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Another problem with tostring() is that it seems you have to call it with encoding="unicode". Perhaps it would be better to suggest code like "".join(element.itertext())?

I would also improve on Jérôme’s version by making the None case more explicit. And perhaps both attributes can be defined together, rather than giving a half-hearted definition linking between them:

.. attribute:: text
.. attribute:: tail

   The *text* attribute holds any text between the element's begin tag and the next tag. The *tail* attribute holds any text between the element's end tag and the next tag. These attributes are set to ``None`` if there is no text. For example, in the XML data ``<a><b>1<c>2<d/>3</c></b>4</a>``, the *a* element has ``None`` for both *text* and *tail* attributes, the *b* element has *text* ``"1"`` and *tail* ``"4"``, the *c* element has *text* ``"2"`` and *tail* ``None``, the *d* element has *text* ``None`` and *tail* ``"3"``.
   To collect the inner text of an element, use :meth:`itertext`, for example ``"".join(element.itertext())``.
   Applications may store arbitrary objects in these attributes.
Date User Action Args
2015-05-13 04:06:07martin.pantersetrecipients: + martin.panter, rhettinger, scoder, ned.deily, eli.bendersky, docs@python, jlaurens
2015-05-13 04:06:07martin.pantersetmessageid: <>
2015-05-13 04:06:07martin.panterlinkissue24079 messages
2015-05-13 04:06:07martin.pantercreate