def peek(file, length=1):
    """Helper function for reading *length* bytes from *file* without advancing
    the current position."""
    pos = file.tell()
    data = file.read(length)
    file.seek(pos)
    return data