Is there any way to get the following output (especially the 1,4c1,4 syntax) from Python's difflib?
diff foo baz
1,4c1,4
< 'asdf'
< 'asdf'
< 'asdf'
< 'asdf'
---
> asdf
> asdf
> asdf
> asdf
Is there any way to get the following output (especially the 1,4c1,4 syntax) from Python's difflib?
diff foo baz
1,4c1,4
< 'asdf'
< 'asdf'
< 'asdf'
< 'asdf'
---
> asdf
> asdf
> asdf
> asdf
There's a good implementation here: https://github.com/glanois/code/blob/master/python/ppt/diff.py
Its header comment says:
This class produces differences in the POSIX default format (see http://www.unix.com/man-page/POSIX/1posix/diff/), which is the same as the Gnu diff "normal format" (see http://www.gnu.org/software/diffutils/manual/diffutils.html#Normal).
I tested it with python 2.7, producing the following output for your example:
$ python diff.py foo baz
1,4c1,4
< 'asdf'
< 'asdf'
< 'asdf'
< 'asdf'
---
> asdf
> asdf
> asdf
> asdf