def __init__(self, tag, attrib=_Attrib(), **extra): super(Element, self).__init__(tag) self.attrib = _Attrib() if attrib: self.attrib.update(attrib) if extra: self.attrib.update(extra)
def SubElement(parent, tag, attrib=_Attrib(), **extra): """Must override SubElement as well otherwise _elementtree.SubElement fails if 'parent' is a subclass of Element object. """ element = parent.__class__(tag, attrib, **extra) parent.append(element) return element