title: Python convert string to hex then convert to bytes
body: <p>I have this string :</p>
  <pre><code>cmd_str = '02003311c3002404005803 '
  </code></pre>
  <p>When I convert this to bytes I get  this. (using windows 10 Python 3)</p>
  <pre><code>b'\x02\x003\x11\xc3\x00$\x04\x00X\x03'
  </code></pre>
  <p>I expected to get this:</p>
  <pre><code>b'\x02\0x0\0x33\33\0x11\0xc3\0x0\0x24\0x4\0x0\0x58\0x3'
  </code></pre>
  <p>Why?</p>
  <pre><code>cmd_str = '02'+'00'+'33'+'11'+'c3'+'00'+'24'+'04'+'00'+'58'+'03'
  
  n = 2
  
  out = [(cmd_str[i:i+n]) for i in range(0, len(cmd_str), n)]
  
  hexlist=[]   
  for i in out:
      an_integer = int(i,16)  #read string in convert to integer.
          
      hex_v=hex(an_integer)
      print(hex_v)
      hexlist.append(hex_v)
  result = bytes([int(x,0) for x in hexlist])
  </code></pre>