Dec-21-2019, 12:36 PM
One should make unambiguous what does 'difference' means.
For example, using difflib.Differ() one will get differences as follows (provided data in files named diff_1.txt and diff_2.txt respectively):
For example, using difflib.Differ() one will get differences as follows (provided data in files named diff_1.txt and diff_2.txt respectively):
with open('diff_1.txt', 'r') as x, open('diff_2.txt', 'r') as y: diff = difflib.Differ().compare(x.readlines(), y.readlines()) different_rows = (value.strip() for value in diff if value.startswith(('+', '-'))) print(*different_rows, sep='\n')
Output:+ 4
+ 6
- 6
- 7
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.