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