Rowana Ravenclaw
Rowana Ravenclaw

Reputation: 105

Could someone explian the DiffLib library?

According to the Python documentation here: https://docs.python.org/2/library/difflib.html , when I am comparing two sequences '+' is appended when the line is unique to sequence1 and '-' for sequence2. '? ' is appended when line is not present in either input sequence. What does this mean? Could someone explain me when a '?' is appended?

Upvotes: 1

Views: 218

Answers (2)

ekhumoro
ekhumoro

Reputation: 120798

There is some further explanation below the table you are referring to:

Lines beginning with ‘?‘ attempt to guide the eye to intraline differences, and were not present in either input sequence.

Which is not particularly clear, but means that the lines are merely explantory, and not part of the actual diff output. The example for ndiff makes this clearer:

>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
...              'ore\ntree\nemu\n'.splitlines(1))
>>> print ''.join(diff),
- one
?  ^
+ ore
?  ^

So the ^ symbol is simply pointing to where the differences are.

Upvotes: 1

Patrick the Cat
Patrick the Cat

Reputation: 2168

On the same section of the doc you linked:

Lines beginning with ‘?‘ attempt to guide the eye to intraline differences, and were not present in either input sequence.

It's solely for visualization purposes.

Upvotes: 1

Related Questions