[Tutor] File Compare
Dave Angel
davea at davea.name
Fri Jan 9 07:42:32 CET 2015
On 01/09/2015 01:24 AM, Crusier wrote:
> Hi Danny,
>
> Thanks for your suggestion.
>
> The ideal of output of this program is to show if there is any new
> number added to the new file.
>
> In other words, the file content of file1 [0001.hk, 0002.hk, 0003.hk,
> 0004.hk] is comparing with the file content of file2 [0001.hk,
> 0002.hk, 0003.hk, 0005.hk].
>
But your files don't have commas in them. Either make sure there's a
comma after each item, or change the delimiter you use to split with. I
suspect you'd be happier with the latter, since there are also newlines
in the file, so it'd be more work to get what you want with comma
delimiting.
> The result should be +0005.hk, -0004.hk
That's not what unified_diff is documented to do. It produces each diff
item with context around it. The default number of lines of context is
3, so you might try changing that with the keyword argument n= to
unified_diff.
See also my earlier message showing you the first two problems with your
code.
--
DaveA
More information about the Tutor
mailing list