Any way to adjust difflib algorithm?

Aahz aahz at pythoncraft.com
Wed Aug 19 15:43:00 EDT 2009


In article <FMqdncOMnPg-JRjXnZ2dnUVZ_tti4p2d at posted.visi>,
Grant Edwards  <invalid at invalid> wrote:
>On 2009-08-14, Grant Edwards <invalid at invalid> wrote:
>>
>> 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.

Good work!  Note that IME most diff software shows changed lines as a
delete-and-add.  For example, diff -u
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Given that C++ has pointers and typecasts, it's really hard to have a
serious conversation about type safety with a C++ programmer and keep a
straight face.  It's kind of like having a guy who juggles chainsaws
wearing body armor arguing with a guy who juggles rubber chickens wearing
a T-shirt about who's in more danger."  --Roy Smith



More information about the Python-list mailing list