title: When reading bytes from a file, reads it like a list
body: <p>When I'm reading bytes from file using
  <code>open(&quot;file.txt&quot;, &quot;rb&quot;&quot;)</code> python adds brackets in the beginning and end of the bytes, like list.</p>
  <p>I've tried to manually cut the brackets using <code>re.sub</code> but because it is a list, I got an error code saying <code>TypeError: expected string or bytes-like object</code> since it's a list.
  (The reason I used <code>f.readlines(0)</code> below instead of just normal file reading is because I store other variables on this file)</p>
  <pre><code>&gt;&gt;&gt; foo = os.urandom(&quot;128&quot;)
  &gt;&gt;&gt; print(foo) 
  b'\xb9\xfe\xeb\x03e\xe8\x8e\x0c\xc1\x05\xb1\xe8\xadB\x9d\xdf_-\xd2\x8c\x18\xe2\xb2\xc7\xf9I\x18\xa7(\xefe\xc9\xc4:\xb3\x93\n+\x7f\x8e\xd2\x82\xf0!\x9668\x01\xcdf\x0f\x15\xe6r\xec\x01\xb8\x7f\x8d\xa25\xd6yq\x1e#\xfb\x0eY\x0fE\x1a)V\xb2\xcb_\x89yH\xd9\xf9\xc7.\x12\x98\x16\xe4!k\xdfU&gt;\xa2\xf0H\xcbT3.\xbd\xbdn\x8aU&lt;\xeb\xf7\xca\xd6~\xf2R\xca\x0f\x8f\x9d\xce\xd8D\xa6f,H\xf8\xcc\xca\x1f' 
  &gt;&gt;&gt; f = open(&quot;t.text&quot;, &quot;wb&quot;) 
  &gt;&gt;&gt; f.write(foo)
  &gt;&gt;&gt; f.close() 
  &gt;&gt;&gt; f = open(&quot;t.text&quot;, &quot;rb&quot;) 
  &gt;&gt;&gt; bar = f.readlines(0)
  &gt;&gt;&gt; print(bar)
  [b'\xb9\xfe\xeb\x03e\xe8\x8e\x0c\xc1\x05\xb1\xe8\xadB\x9d\xdf_-\xd2\x8c\x18\xe2\xb2\xc7\xf9I\x18\xa7(\xefe\xc9\xc4:\xb3\x93\n', b'+\x7f\x8e\xd2\x82\xf0!\x9668\x01\xcdf\x0f\x15\xe6r\xec\x01\xb8\x7f\x8d\xa25\xd6yq\x1e#\xfb\x0eY\x0fE\x1a)V\xb2\xcb_\x89yH\xd9\xf9\xc7.\x12\x98\x16\xe4!k\xdfU&gt;\xa2\xf0H\xcbT3.\xbd\xbdn\x8aU&lt;\xeb\xf7\xca\xd6~\xf2R\xca\x0f\x8f\x9d\xce\xd8D\xa6f,H\xf8\xcc\xca\x1f\xcc\x96\xaa\x9d\xc5\xebE\xc8\x0b\xe6G&quot;\xb9\xf1T\x80']
  </code></pre>
  <p>How can I read it as bytes instead of list?
  (I store other bytes on different lines, this on line 1 and another on line 2. I can't store them on different files).</p>
  <p>EDIT: The solution is this: f.read(data_size).</p>