Visual diff using python

DMP is a library written in multiple languages and is used to compare two texts: Diff Match and Patch project homepage.

Download this freely available and fast Python code, copy it inside the directory of your script. Now you can generate diff and output it to HTML by writing simple program, such as:

text1 = """Lorem ipsum amet, REPLACE adipiscing elit. Integer
eu lacus accumsan arcu euismod. Donec pulvinar porttitor"""

text2 = """Lorem ipsum amet, consectetuer adipiscing elit. Integer
eu lacus accumsan arcu euismod. ADD Donec pulvinar porttitor"""

from diff_match_patch import diff_match_patch

dmp = diff_match_patch()
mydiff = dmp.diff_main(text1, text2)
myHTML = dmp.diff_prettyHtml(mydiff)

file = open("test.html","w")
file.write(myHTML)
file.close()

I heard rumors that python's difflib is not that fast :)