I am trying to compare two sequences using difflib.Differ()
. However, I am observing some unwanted differences which I am not able to understand. Can someone please explain this behavior and how this can be resolved?
import difflib
a = "abc-123 Abcdef"
b = "abc-123 Abcdef-def"
a = a.strip("\n")
b = b.strip("\n")
a = a.split(" ")
b = b.split(" ")
d = difflib.Differ()
result = list(d.compare(a,b))
for s in result:
if s[0] == ' ':
continue
print s
Output:
- Abcdef
+ Abcdef-def
? ++++
Why is the ?
difference reported here? I would expect only first two differences to be reported (changes only).