title: Python: Converting HEX string to bytes
body: <p>I'm trying to make byte frame which I will send via UDP. I have class <strong>Frame</strong> which has attributes <strong>sync</strong>, <strong>frameSize</strong>, <strong>data</strong>, <strong>checksum</strong> etc. I'm using hex strings for value representation. Like this:</p>
  
  <pre><code>testFrame = Frame("AA01","0034","44853600","D43F")
  </code></pre>
  
  <p>Now, I need to concatenate this hex values together and convert them to byte array like this?!</p>
  
  <pre><code>def convertToBits(self):
      stringMessage = self.sync + self.frameSize + self.data + self.chk
      return b16decode(self.stringMessage)
  </code></pre>
  
  <p>But when I print converted value I don't get the same values or I don't know to read python notation correctly:</p>
  
  <pre><code>This is sync: AA01
  This is frame size: 0034
  This is data:44853600
  This is checksum: D43F
  
  b'\xaa\x01\x004D\x856\x00\xd4?'
  </code></pre>
  
  <p>So, first word is converted ok (AA01 -> \xaa\x01) but (0034 -> \x004D) it's not the same. I tried to use <strong>bytearray.fromhex</strong> because I can use spaces between bytes but I got same result. Can you help me to send same hex words via UDP?</p>