[docs] Provide some examples for usage of ElementTree methods/attributes (issue 15586)

ezio.melotti at gmail.com ezio.melotti at gmail.com
Thu Aug 9 10:51:48 CEST 2012


http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementtree.rst
File Doc/library/xml.etree.elementtree.rst (right):

http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementtree.rst#newcode129
Doc/library/xml.etree.elementtree.rst:129: :meth:`Element.text` accesses
the element's content::
I would rephrase this paragraph to have 3 sentences: the first about
findall, the second about find and text, and the third about get.

+ :meth:`Element.get` safely accesses attributes.
Why safely? What happens if the attribute is missing? (I'm not saying
these should be answered here, but the use of "safely" makes me wonder).

+:meth:`Element.text` accesses the element's content
Is the "content" only text nodes?

http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementtree.rst#newcode133
Doc/library/xml.etree.elementtree.rst:133: ...  
print(country.get('name'), rank)
I would change the last line to:
name = country.get('name')
print(name, rank)

so that the methods used in the first 3 lines matches the 3 sentences in
the previous paragraph.

http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementtree.rst#newcode137
Doc/library/xml.etree.elementtree.rst:137: 68 Panama
If you printed name and rank, why are these showing rank and name?

http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementtree.rst#newcode153
Doc/library/xml.etree.elementtree.rst:153: Let's say we want to subtract
one from each country's rank::
s/subtract/add/

http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementtree.rst#newcode158
Doc/library/xml.etree.elementtree.rst:158: ...   rank.set('updated',
'yes')
I would add something like ", and add an ``updated`` attribute to the
rank element" or ", and mark it with an ``updated`` attribute" to the
previous sentence.

http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementtree.rst#newcode159
Doc/library/xml.etree.elementtree.rst:159: ... tree.write('output.xml')
Leave an empty line before this (same with the following examples).

http://bugs.python.org/review/15586/


More information about the docs mailing list