def _parse_property ( self , node ) : # type: (ElementTree.Element) -> Tuple[str, Any] # Get information name = node . attrib [ ATTR_NAME ] vtype = node . attrib . get ( ATTR_VALUE_TYPE , TYPE_STRING ) # Look for a value as a single child node try : value_node = next ( iter ( node ) ) value = self . _parse_value_node ( vtype , value_node ) except StopIteration : # Value is an attribute value = self . _convert_value ( vtype , node . attrib [ ATTR_VALUE ] ) return name , value
parsing a childnode's attribute in python 3
Parses a property node
def _parse_property(self, node):
        # type: (ElementTree.Element) -> Tuple[str, Any]
        """
        Parses a property node

        :param node: The property node
        :return: A (name, value) tuple
        :raise KeyError: Attribute missing
        """
        # Get information
        name = node.attrib[ATTR_NAME]
        vtype = node.attrib.get(ATTR_VALUE_TYPE, TYPE_STRING)

        # Look for a value as a single child node
        try:
            value_node = next(iter(node))
            value = self._parse_value_node(vtype, value_node)
        except StopIteration:
            # Value is an attribute
            value = self._convert_value(vtype, node.attrib[ATTR_VALUE])

        return name, value