title: Convert Python str/unicode object to binary/hex blob
body: <p>Is there an easy way to get some str/unicode object represented as a big binary number (or an hex one)?</p>
  
  <p>I've been reading some answers to related questions but none of them works for my scenario.</p>
  
  <p>I tried using the <a href="http://docs.python.org/library/struct.html" rel="noreferrer">struct</a> module from the <strong>STL</strong> but it didn't work as expected. Chars, like in binary files are displayed as, well chars.</p>
  
  <p>Am I trying something impossible?</p>
  
  <p>Example:</p>
  
  <pre><code>def strbin(inp):
      # sorcery!
      return out
  
  &gt;&gt; print strbin("hello")
  # Any of these is cool (outputs are random keystrokes)
  0b1001010101010000111001110001...
  0xad9f...
  </code></pre>