title: Python writing hex to a file
body: <p>I'm using Python 3 and I want to be able to write hex to a file like this but i cannot get it to work. This gives me a TypeError and if encode it the output to the file isn't correct. </p>
  
  <pre><code>junk = '\x90' * 5
  junk += '\xcc' * 5
  
  fo = open("foo.list", "wb")
  
  fo.write(junk)
  fo.close()
  </code></pre>
  
  <p>this gives me a <code>type error, str doesn't support the buffer interface</code>, if i however do this</p>
  
  <pre><code>junk = '01BDF23A'
  junk += '90' * 5
  junk += 'cc' * 5
  
  
  fo = open("foo3.m3u", "wb")
  fo.write(binascii.unhexlify(junk))
  fo.close()
  </code></pre>
  
  <p>it works but i would like to define them as hex (\x90), any ideas?</p>
  
  <p>Thanks in advance for any help!</p>