diff = difflib.context_diff(fromlines, tolines, fromfile='file1.txt',
    tofile='file2.txt')
sys.stdout.writelines(diff)
How to use Python's difflib to produce side-by-side comparison of two files similar to Unix sdiff command?