I have two log files that I am trying to compare, in bash
:
$ diff logfile_56.log logfile_57.log
returns nothing.
However, when I do the following with difflib.ndiff
I get the following:
import difflib
with ('logfile_56.log', 'r') as file_one:
content_one = file_one.readlines()
with ('logfile_57.log', 'r') as file_two:
content_two = file_two.readlines()
delta = difflib.ndiff(content_one, content_two)
if len(list(delta)) == 0:
print('Diff exists!')
This shows me that a diff exists, even when there isn't one. Although I see no '+' or '-' in the output and just the content of logfile_57.log instead. How should I be successfully detecting whether a diff exists or not? I can check the delta
variable for +
or -
but, it is likely that the contents of either of these files would contain those characters anyway.
I'd like to use ndiff
because the output when a diff does exist is something that works perfectly for my use case.
Am I doing something wrong?