[Python-ideas] enhance filecmp to support text-and-universal-newline-mode file comparison

zhong nanhai higerinbeijing at gmail.com
Thu Jun 18 16:04:34 CEST 2009

Hello everyone:

We know that we often use programmes or scripts to generate useful
output files ,but these files may come from different OS platforms.

Comparing them by reading line by line may seem a bit trivial and we
can use the filecmp model to do such thing(the cmp function). But
when we try to compare two text files from different platforms,e.g.
Ubuntu and Windows, even though these two files contain the same
content, the filecmp.cmp will return false.We know that the reason is
different ways to handle newline flag in different platforms, '\n\r'
for Windows,'\n' for Unix,'\r' for Mac, e.t.c.

So is it a good idea to enhance the filecmp to support
universal-newline-mode?If so, we can compare different files from
different operation systems and if they have the same content, the
filecmp.cmp would return true.

Hoping everyone can give some advice about this idea.
Thanks in advance,

More information about the Python-ideas mailing list