i patch a list to look like another:
a = [x for x in "qabxcd"]b = [x for x in "abycdf"]c = a[:]s = SequenceMatcher(None, a, b)for tag, i1, i2, j1, j2 in s.get_opcodes(): print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) if tag == "delete": del c[i1:i2] elif tag == "replace": c[i1:i2] = b[j1-1:j2-1] elif tag == "insert": c[i1:i2] = b[j1:j2]print cprint bprint c == ba == bbut the list is not equal:
delete a[0:1] (['q']) b[0:0] ([]) equal a[1:3] (['a', 'b']) b[0:2] (['a', 'b'])replace a[3:4] (['x']) b[2:3] (['y']) equal a[4:6] (['c', 'd']) b[3:5] (['c', 'd']) insert a[6:6] ([]) b[5:6] (['f'])['a', 'b', 'x', 'b', 'd', 'f']['a', 'b', 'y', 'c', 'd', 'f']Falsewhat is the problem?