From ae2c6c6606b65d3ecc6f447306470f630d1b71b2 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Mon, 25 Jun 2018 14:46:47 +0300 Subject: [PATCH 1/2] Write documentation strings within xml.dom.minidom module Write documentation string for xml.dom.minidom.Element.getAttribute method. I think it would be better to know what exactly it returns from pydoc. --- Lib/xml/dom/minidom.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index e44e04a069ecb4..8860424d5c21ed 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -718,6 +718,14 @@ def unlink(self): Node.unlink(self) def getAttribute(self, attname): + """Returns the value of the specified attribute. + + Returns the value of the element's attribute named attname as + a string. An empty string is returned if the element does not + have such an attribute. Note that an empty string may also be + returned as an explicitly given attribute value, use the + hasAttribute method to distinguish these two cases. + """ if self._attrs is None: return "" try: @@ -828,6 +836,11 @@ def removeAttributeNode(self, node): removeAttributeNodeNS = removeAttributeNode def hasAttribute(self, name): + """Checks whether the element has an attribute with the specified name. + + Returns True if the element has an attribute with the specified name. + Otherwise, returns False. + """ if self._attrs is None: return False return name in self._attrs From 40dc45ce14caaa2f4e4f039d1ec1e3a8547ab2c1 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Mon, 25 Jun 2018 15:08:25 +0300 Subject: [PATCH 2/2] Write more docstrings to xml.dom.minidom Also write a documentation string for getElementsByTagName method to note that it returns not only direct children. --- Lib/xml/dom/minidom.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 8860424d5c21ed..0e462f440a53f3 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -851,6 +851,11 @@ def hasAttributeNS(self, namespaceURI, localName): return (namespaceURI, localName) in self._attrsNS def getElementsByTagName(self, name): + """Returns all descendant elements with the given tag name. + + Returns the list of all descendant elements (not direct children + only) with the specified tag name. + """ return _get_elements_by_tagName_helper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName):