Skip to content

Instantly share code, notes, and snippets.

@zhasm
Created August 9, 2012 11:46
Show Gist options
  • Save zhasm/3303542 to your computer and use it in GitHub Desktop.
Save zhasm/3303542 to your computer and use it in GitHub Desktop.
compare 2 blocks of text
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from difflib import unified_diff
def getRawInput(name):
ret=[]
ret.append(raw_input("Please copy a bunch of lines as %s, and press Enter && Ctrl-D to end: \n\n" % name ).strip())
while True:
try:
ret.append(raw_input().strip())
except EOFError:
break
return ret
if __name__ == '__main__':
a=getRawInput('A')
print '\n', '='*32, '\n'
b=getRawInput('B')
for line in unified_diff(a, b):
print line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment