title: Python: reading and printing a binary file
body: <p>I have a binary file and I want to read the data, one byte at a time, printing each byte as it runs.</p>
  
  <p>The code I have so far is:</p>
  
  <pre><code>f = open("test.dat", "rb")
  try:
      byte = f.read(1)
      while byte != "":
          print byte
          raw_input("Press Enter to continue...")
          byte = f.read(1)
  finally:
      f.close()
  </code></pre>
  
  <p>However, this is not giving me expected results. Basically, I want to print out a number between 0 and 127 for each byte. However, the first print gives me a smiley face symbol, which I know is not within the first 128 entries in ASCII. Therefore, it seems I am printing out more than just a byte - even though I have specified only to read 1 byte in f.read.</p>
  
  <p>What's going on here?</p>
  
  <p>Thanks.</p>