Any way to adjust difflib algorithm?

Grant Edwards invalid at invalid
Fri Aug 14 15:18:59 EDT 2009


On 2009-08-14, Grant Edwards <invalid at invalid> wrote:

> I'm trying to use difflib to compare two files, and it's not
> producing very useful results.  When comparing two lines where
> only a few characters have changed, it usually seems to decide
> that a line was deleted/inserted/replaced rather than changed.

[...]

> In my particular usage, no lines have ever been
> inserted/deleted, so perhaps I should be running diffs on
> individual lines instead?  If I do that, I can't figure out
> how to generate HTML output.

I ended up using the SequenceMatcher on individual pairs of
lines and generating my own HTML based on the results of
get_matching_blocks().

That produced the desired results.

-- 
Grant Edwards                   grante             Yow! I have a very good
                                  at               DENTAL PLAN.  Thank you.
                               visi.com            



More information about the Python-list mailing list