Re: [docs] Provide some examples for usage of ElementTree methods/attributes (issue 15586)
http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementt... File Doc/library/xml.etree.elementtree.rst (right): http://bugs.python.org/review/15586/diff/5683/Doc/library/xml.etree.elementt... 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.elementt... 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.elementt... 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.elementt... 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.elementt... 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.elementt... 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/
participants (1)
-
ezio.melotti@gmail.com