difflib.ndiff broken?

Humpdydum oliver.schoenborn at utoronto.ca
Thu Jul 15 18:44:52 EDT 2004


OK, forget it, sorry it was my mistake: it wasn't obvious from the difflib
docs, but it appears that ndiff points out the sub-line differences (lines
that start with ?) only if it was able to figure out operations that could
be applied to substrings on the line. Though often such operations are
obvious by looking at the strings being compared, ndiff doesn't always find
them, and so marks the whole line as + or -.

Anyone know of web site that explains ndiff output? I coulnd't figure out a
good set of search terms in google, didn't get anything useful. Thanks,

Oliver

"Humpdydum" <oliver.schoenborn at utoronto.ca> wrote in message
news:cd6r1o$50e$1 at nrc-news.nrc.ca...
> Can anyone try the following in their python interpreter?
>
> These give correct output:
>
> >>> print list(ndiff(['saving2 <<A'],['saving <<a>>']))
> ['- saving2 <<A', '?       -   ^\n', '+ saving <<a>>', '?          ^^^\n']
> >>> print list(ndiff(['saving2 <<AA'],['saving <<a>>']))
> ['- saving2 <<AA', '?       -   ^^\n', '+ saving <<a>>', '?
^^^\n']
> >>> print list(ndiff(['saving2 <<A'],['saving <<aa>>']))
> ['- saving2 <<A', '?       -   ^\n', '+ saving <<aa>>', '?
^^^^\n']
> >>> print list(ndiff(['saving <<A'],['saving <<aa>>']))
> ['- saving <<A', '?          ^\n', '+ saving <<aa>>', '?          ^^^^\n']
>
> Now try the very slight variations:
>
> >>> print list(ndiff(['saving2 <<AA'],['saving <<aa>>']))
> ['- saving2 <<AA', '+ saving <<aa>>']
> >>> print list(ndiff(['saving2 <<AA'],['saving <<aa>>']))
> ['- saving2 <<AA', '+ saving <<aa>>']
>
> This can't be right... or is it? Where are the '? ...' lines?





More information about the Python-list mailing list