Unix diff algorithm in Python anyone?

Preston Landers prestonlanders at my-deja.com
Tue Oct 5 12:32:57 EDT 1999


In article <7td5lp$2oc$1 at nnrp1.deja.com>,
  harri.pasanen at trema.com wrote:

> I made some effort to track down a python module that could be used as
> unix diff.  Currently I'm in fact popen'ing diff itself, but for I'd
> like to have a self-contained utility.

Harri,

I'm not quite sure why opening a channel to Unix diff isn't going to
work for you.  Do you absolutely need a cross-platform solution?  There
is probably a diff availible for most computers.

Why reimplement it from scratch?  While not extraordinarily complex, a
lot of thought and debugging has gone into GNU diff. Why not leverage
that work?

status, result = commands.getstatusoutput("diff %s %s" % (file1, file2))

has worked fine for me.

It might be a good idea to build a Python *wrapper* around a command-
line diff, one that would handle diff options and so on intelligently,
maybe also interface with patch.

However, if I were you, I wouldn't waste time re-writing diff in
Python.  I'm sure some people would beg to differ.

yours,

---Preston


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list