title: Write a hex string as binary data in Python
body: <p>I have a string of data like <code>FF0000FF</code> and I want to write that to a file as raw 8-bit bytes <code>11111111 00000000 00000000 11111111</code>.  However, I seem to end up getting way to much data <code>FF</code> turns into <code>FF 00 00 00</code> when using <code>struct.pack</code> or I get a literal ASCII version of the 0's and 1's.</p>
  
  <p>How can I simply take a string of hex and write that as binary, so when viewed in a hex-editor, you see the same hex string? </p>