diff lists
Michael Hudson
mwh21 at cam.ac.uk
Thu Mar 29 19:16:41 EST 2001
"Tim Peters" <tim.one at home.com> writes:
> [Michael Hudson]
> > Tangentially, does anyone know of any good algorithms for "edit
> > distance" between two sequences? E.g. if I have
> >
> > "abcdef"
> >
> > and want to get to
> >
> > "abQUACKcde"
> >
> > I want to get the answer back "insert 'QUACK' at position 3 and delete
> > a character at position 11".
>
> See std library module difflib.py (new in 2.1). This packages the
> SequenceMatcher class from the heart of the Tools/scripts/ndiff.py tool for
> easy reuse.
Ah yes; I knew about that and thought it was probably too
heavy-weight, but admittedly didn't actually try it...
[snip]
> >>> for tag, i1, i2, j1, j2 in m.get_opcodes():
... or look close enough to find the get_opcodes methods. I'll give
it a whirl.
Thanks!
M.
--
ARTHUR: But which is probably incapable of drinking the coffee.
-- The Hitch-Hikers Guide to the Galaxy, Episode 6
More information about the Python-list
mailing list