title: Confused about Python bytes type
body: <p>I'm reading a binary file (Python 3) and am trying to convert chunks with the help of the <strong>struct</strong> module.</p>
  
  <pre><code>f = open(fn, "rb")
  try:
      a=f.read(2)
  ...
  </code></pre>
  
  <p>When I use : </p>
  
  <pre><code>unpack("h",b'\x6b\x0a')
  </code></pre>
  
  <p>it gives me the expected </p>
  
  <pre><code>(2667,)
  </code></pre>
  
  <p>But I can't use that syntax on </p>
  
  <pre><code>b'6b0a' 
  </code></pre>
  
  <p>even though:</p>
  
  <pre><code>print(type(b'6b0a'))
  print(type(b'\x6b\x0a'))
  </code></pre>
  
  <p>gives the same type:</p>
  
  <pre><code>&lt;class 'bytes'&gt;
  &lt;class 'bytes'&gt;
  </code></pre>
  
  <p>What am I mixing up? I think this used to work for me in Python 2.x.</p>