title: How to read a file byte by byte in Python and how to print a bytelist as a binary?
body: <p>I'm trying to read a file byte by byte, but I'm not sure how to do that. I'm trying to do it like that:</p>
  
  <pre><code>file = open(filename, 'rb')
  while 1:
     byte = file.read(8)
     # Do something...
  </code></pre>
  
  <p>So does that make the variable byte to contain 8 next bits at the beginning of every loop? It doesn't matter what those bytes really are. The only thing that matters is that I need to read a file in 8-bit stacks.</p>
  
  <p>EDIT:</p>
  
  <p>Also I collect those bytes in a list and I would like to print them so that they don't print out as ASCII characters, but as raw bytes i.e. when I print that bytelist it gives the result as</p>
  
  <pre><code>['10010101', '00011100', .... ]
  </code></pre>