How to compare files

Terry Hancock hancock at anansispaceworks.com
Fri Jul 1 15:08:57 EDT 2005


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




More information about the Python-list mailing list