python - Diffing two files while ignoring any missed lines -
i diffing 2 unsorted files , problem moment 1 of files gets line not present in other file, diff goes off. want write/print line not present , continue on. import re f1=open("file1","r") f2=open("file2","r") f=open("output","w") test_lines=f1.readlines() correct_lines=f2.readlines() test, correct in zip(sorted(test_lines), sorted(correct_lines)): if test.strip().split("(")[0].replace(" ","").strip() != correct.strip().split("(")[0].replace(" ","").strip() , test!="\n": print "oh no! expected %r; got %r." % (correct, test) else: towrite=correct + test f.write(towrite) else: len_diff = len(test_lines) - len(correct_lines) if len_diff > 0: print "test file had data." elif len_diff < 0: print "test file had little data." else: print "everythin