Understanding the arguments for SubElement factory in ElementTree

B Mahoney mrbmahoney at gmail.com
Sat Oct 29 20:08:55 CEST 2005

Your SubElement call is lacking the attrib argument, but you can't set
text, anyway.

The elementtree source makes it clear, you can only set element attrib
with SubElement

def SubElement(parent, tag, attrib={}, **extra):
    attrib = attrib.copy()
    element = parent.makeelement(tag, attrib)
    return element

More information about the Python-list mailing list