import lxml.etree as ET
import lxml.builder as builder
E = builder.ElementMaker(namespace='http://www.cs.rpi.edu/XGMML', nsmap={
    None: 'http://www.cs.rpi.edu/XGMML', 'dc':
    'http://purl.org/dc/elements/1.1/', 'xlink':
    'http://www.w3.org/1999/xlink', 'rdf':
    'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'cy':
    'http://www.cytoscape.org'})
graph = E.graph(label='Test', directed='1')
How to write namespaced element attributes with LXML?