title: python - lxml: enforcing a specific order for attributes
body: <p>I have an XML writing script that outputs XML for a specific 3rd party tool. </p>
  
  <p>I've used the original XML as a template to make sure that I'm building all the correct elements, but the final XML does not appear like the original. </p>
  
  <p>I write the attributes in the same order, but lxml is writing them in its own order. </p>
  
  <p>I'm not sure, but I suspect that the 3rd part tool expects attributes to appear in a specific order, and I'd like to resolve this issue so I can see if its the attrib order that making it fail, or something else. </p>
  
  <p>Source element:</p>
  
  <pre><code>&lt;FileFormat ID="1" Name="Development Signature" PUID="dev/1" Version="1.0" MIMEType="text/x-test-signature"&gt; 
  </code></pre>
  
  <p>My source script:</p>
  
  <pre><code>sig.fileformat = etree.SubElement(sig.fileformats, "FileFormat", ID = str(db.ID), Name = db.name, PUID="fileSig/{}".format(str(db.ID)), Version = "", MIMEType = "")
  </code></pre>
  
  <p>My resultant XML:</p>
  
  <pre><code>&lt;FileFormat MIMEType="" PUID="fileSig/19" Version="" Name="Printer Info File" ID="19"&gt;
  </code></pre>
  
  <p>Is there a way of constraining the order they are written? </p>