Re: How to compare files
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: How to compare files

From: Terry Hancock <hancock@anansispaceworks.com>
Date: Fri Jul 01 2005 - 21:08:57 CEST

On Friday 01 July 2005 04:39 am, Lad wrote:
> Hi,
> What is the best method for comparing two files by words?
> I was thinking about reading files by words and compare them but a word
> in one file can be linked with a new line character ( \n)
> and this '\n' will cause that the words will considered to be
> different( eventhough without '\n' are the same)

Use the split from re instead of the string method, and
include all the non-word characters (including '\n') as
whitespace characters. Then you'll have only words
(I think you can also wind up with empty strings, which
you can strip out pretty easily).

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com
Received on Thu Sep 29 16:41:54 2005