I am using difflib to identify all the matches of a short string in a longer sequence. However it seems that when there are multiple matches, difflib only returns one:
> sm = difflib.SequenceMatcher(None, a='ACT', b='ACTGACT')
> sm.get_matching_blocks()
[Match(a=0, b=0, size=3), Match(a=3, b=7, size=0)]
The output I expected was:
[Match(a=0, b=0, size=3), Match(a=0, b=4, size=3), Match(a=3, b=7, size=0)]
In fact the string ACTGACT contains two matches of ACT, at positions 0 and 4, both of size 3 (plus another match of size 0 at the end of the strings).
How can I get multiple matches? I was expecting difflib to return both positions.