git likes to write stuff to temporary files, and then pass the name of the file on to git hooks. So following that pattern, you could just write your output to a temporary file, and call less with subprocess.Popen: