Stefan Behnel added the comment:
The can store arbitrary objects sentence is now duplicated, and still way too
visible. I have to read three sentences until it tells me what I need to know.
--
___
Python tracker rep...@bugs.python.org
Stefan Behnel added the comment:
I think the first two sentences can simply be removed to fix this, without loss
of readability or information.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24079
Ned Deily added the comment:
Thanks for all of your contributions on this. I've committed a version along
the lines I suggested along with Martin's example.
--
resolution: - fixed
stage: commit review - resolved
status: open - closed
type: behavior -
Roundup Robot added the comment:
New changeset d3cda8cf4d42 by Ned Deily in branch '2.7':
Issue #24079: Improve description of the text and tail attributes for
https://hg.python.org/cpython/rev/d3cda8cf4d42
New changeset ad0491f85050 by Ned Deily in branch '3.4':
Issue #24079: Improve
Robert Collins added the comment:
So it is downplayed but it is still documented as being application usable.
I'll give this another week for Ned to reply, then commit it in the absence of
a reply: I think its ok as is. I'd be ok with a tweaked version along the lines
Ned proposed too: both
Martin Panter added the comment:
I think Ned’s version is an acceptable solution (modulo some punctuation) to
the original problem, although I do agree with Stefan that downplaying the
generality would be even better.
Perhaps we could add a qualifier, like “The *text* attribute [normally]
Stefan Behnel added the comment:
could we apply this patch, please?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24079
___
___
Ned Deily added the comment:
I note that the current wording for both text and tail are careful to allow
for the most general use of the Element class, that is, that it may be used in
non-XML contexts, for example:
The text attribute can be used to hold additional data associated with the
Stefan Behnel added the comment:
The proposed patch downplays that generality.
That is completely intentional. Almost all readers of the documentation will
first need to understand the difference between text and tail before they can
go and think about any more advanced use cases that will
Changes by Martin Panter vadmium...@gmail.com:
--
stage: patch review - commit review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24079
___
___
Stefan Behnel added the comment:
Looks good to me.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24079
___
___
Python-bugs-list mailing list
Martin Panter added the comment:
Okay, here is a version with most of the wording reverted to Jérôme’s
suggestion. I only left my itertext() example, and the grouping of text and
tail together. If there are any more bits that are incorrect or unclear please
identify them.
--
Added
Stefan Behnel added the comment:
IMHO less clear and less correct than the previous suggestions.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24079
___
Stefan Behnel added the comment:
Seems like a good idea to explain text and tail in one section, though.
That makes tail easier to find for those who are not used to this kind of
split (and that's basically everyone who needs to read the docs in the first
place).
--
Martin Panter added the comment:
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
Raymond Hettinger added the comment:
this is well formed xml and has nothing to do with tail.
In fact, it does have something to do with tail.
The 'TEXT' is a captured as the tail of element b:
root3 = ET.fromstring('ab/TEXT/a')
root3[0].tail
'TEXT'
--
nosy: +eli.bendersky,
Stefan Behnel added the comment:
I agree that the wording in the documentation isn't great:
text
The text attribute can be used to hold additional data associated with the
element. As the name implies this attribute is usually a string but may be any
application-specific object. If the
Jérôme Laurens added the comment:
Since the text and tail notions seem tightly coupled, I would vote for a more
detailed explanation in the text doc and a forward link in the tail
documentation.
text
The text attribute holds the text between the element's begin tag and the
next tag or
Jérôme Laurens added the comment:
Erratum
def innertext(elt):
return (elt.text or '') +''.join(innertext(e)+(e.tail or '') for e in elt)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24079
Jérôme Laurens added the comment:
The totsstring(..., method='text') is not suitable for the inner text because
it adds the tail of the top element.
A proper implementation would be
def innertext(elt):
return (elt.text or '') +''.join(innertext(e)+e.tail for e in elt)
that can be
New submission from Jérôme Laurens:
The documentation for xml.etree.ElementTree.Element.text reads If the element
is created from an XML file the attribute will contain any text found between
the element tags.
import xml.etree.ElementTree as ET
root3 = ET.fromstring('ab/TEXT/a')
Ned Deily added the comment:
(This issue is a followup to your Issue24072.) Again, while the ElementTree
documentation is certainly not nearly as complete as it should be, I don't
think this is a documentation error per se. The key issue is: with which
element is each text string
22 matches
Mail list logo