title: Python: why does peek(1) return 8K bytes instead of 1 byte?
body: <p>I'm using Python 3, and the peek() method for buffered file I/O doesn't seem to work as documented. For example, the following code illustrates the problem -- it prints <strong>8192</strong> as the length of the byte string returned by <code>f.peek(1)</code>:</p>
  
  <pre><code>jpg_file = 'DRM_1851.JPG'
  with open(jpg_file, 'rb') as f:
      next_byte = f.peek(1)
      print(len(next_byte))
  </code></pre>
  
  <p>I sometimes want to peek at the next byte without moving the file pointer, but since the above doesn't work I'm doing something this in those places instead:</p>
  
  <pre><code>next_byte = f.read(1) # read a byte
  f.seek(-1,1) # move the file pointer back one byte
  </code></pre>
  
  <p>That works, but feels like a kludge. Am I misunderstanding something about how peek() works?</p>