title: How to convert Python List of Variable-Type to a Bytes Like Object?
body: <p>So I have an array of mixed types that I want to convert to a bytes like object:</p>
  
  <pre><code>array = [5555, 'North_Terminus', 4444, 0 , 20%3A47]
  </code></pre>
  
  <p>How would would one go about converting this to a bytes like object, preferably encoded in 'utf-8'? I have looked through the Python bytes() &amp; bytesarray() function however the first must be initialized with agiven size and data (integers) and the latter must be mutable, modified sequence of integers in the range 0 &lt;=x &lt; 256.</p>
  
  <p>Error shown below:</p>
  
  <pre><code>    data = bytearray(array)
  ValueError: byte must be in range(0, 256)
  </code></pre>