title: Can you put binary bytes into a ByteArray in python as ints
body: <p>we want to use the binary representation of the number into the bytes array.</p>
  
  <p>When i put a binary 8 bit chunk of code into a Byte Array. The only possible to input that as string as far as i know.
  What i want to be able to do is put this 8 bit binary chunk into the array and when called (as a print) it would output the real number.</p>
  
  <p>example:</p>
  
  <p><strong><em>variable = bin(255)</em></strong></p>
  
  <p>(if i print the result by it'self in a normal statement it comes out as the real number not the bin number i.e <em>print(0b11111111)</em> comes out as <em>255</em>)</p>
  
  <p>it will not allow for me to put it in a byte array like so:
  <strong><em>bytesBit = bytearray([variable])</em></strong>.</p>
  
  <p>But it will allow: <strong><em>bytesBit = bytearray(variable, "utf-8")</em></strong>.</p>
  
  <p>But because it's a string it does when using <em>print(bytesBit[0])</em> it will only print the encoded 0 as "48" instead of the integer interpretation of the binary number. How am i able to do this using python?  </p>
  
  <p>The excuse for needing to do this is because instead of dividing a over 255 character until it is below 255. We instead split the binary in two and put them together in an outside program. I.E 16 bit int into two 8 bit ints to fit into the byte array. </p>