#!/usr/local/bin/python2 import xml.etree.ElementTree as ET e = ET.TreeBuilder() e.start('a', {'b': 'y'}) print e.close()