O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

difflib

The difflib module provides functions and classes for computing differences between lists of strings. The module duplicates the functionality provided by many variants of the popular Unix diff command that’s used to compare files.

context_diff(a,
						b
						[,
						fromfile
						[,
						tofile
						[,
						fromfiledate
						[,
						tofiledate
						[,
						n
						[,
						lineterm]]]]]])

Given two lists of strings, a and b, this function returns a generator object that produces output corresponding to a context-sensitive difference. The output produced by this function is similar to the following:

 *** fromfile fromfiledate --- tofile tofiledate *************** *** 1,9 **** context context context ! modified line context - deleted line context context context --- 1,9 ---- context context context ! ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required