I am using Python 2.6 and I want to create a simple GUI with two side-by-side text panes comparing two text files (file1.txt & file2.txt) .
I am using difflib but it is not clear for me how to produce a result similar to the sdiff Unix command.
In order to reproduce a side-by-side comparison, I need difflib to return two variables file1_diff
and file2_diff
, for instance.
I have also considered to use sdiff output directly and parse it to separate the panes but it turned out not to be as easy as it seems... Any hints?
I've tried to do files diff with difflib.context_diff:
In this case your output will be something like this:
In this case you'll be able easily to separate each file diff, but I'm not sure if you will be satisfied by the output of context_diff. You haven't mentioned in what way you're using the difflib.