On Sep 3, 2:40 pm, [EMAIL PROTECTED] wrote: > Hi, > > I looking for a file comparison utility in Python that works like > 'diff' command in Unix and 'comp' in Windows. > The present 'cmd' in filecmp module only presents output in the form > of 1 or 0 i.e whether the 2 files differ or not? > > So, I'm lookin for something that generates actual differences and > moreover it is cross platform as well. As I need that same thing in > both my windows and linux box. > > Even if it is a utlility please suggest. > > Thanks and regards, > Rajat
What about the difflib module? [EMAIL PROTECTED] test]$ cat file_one abcd 1234 - [EMAIL PROTECTED] test]$ cat file_two abcd 12345 - [EMAIL PROTECTED] test]$ [EMAIL PROTECTED] test]$ python Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11) [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import difflib >>> for i in difflib.context_diff(open("file_one").readlines(), >>> open("file_two").readlines()): ... print i, ... *** --- *************** *** 1,3 **** abcd ! 1234 - --- 1,3 ---- abcd ! 12345 - >>> Also, see http://docs.python.org/lib/module-difflib.html. -Jeff -- http://mail.python.org/mailman/listinfo/python-list