[issue43689] difflib: mention other "problematic" characters in documentation

Tim Peters report at bugs.python.org
Fri Apr 2 22:26:57 EDT 2021


Tim Peters <tim at python.org> added the comment:

Lines beginning with "?" are entirely synthetic: they were not present in either input.  So that's what that part means.

I'm not clear on what else could be materially clearer without greatly bloating the text. For example,

>>> d = difflib.Differ()
>>> for L in d.compare(["abcefghijkl\n"], ["a cxefghijkl\n"]):
	print(L, end="")
- abcefghijkl
?  ^
+ a cxefghijkl
?  ^ +

The "?" lines guide the eye to the places that differ: "b" was replaced by a blank, and "x" was inserted.  The marks on the "?" lines are intended to point out exactly where changes (substitutions, insertions, deletions) occurred.

If the second input had a tab instead of a blank, the "+" wouldn't _appear_ to be under the "x" at all.  It would instead "look like" a long string of blanks was between "a" and "c" in the first input, and the "+" would appear to be under one of them somewhere near the middle of the empty space.

Tough luck. Use tab characters (or any other kind of "goofy" whitespace) in input to visual tools, and you deserve whatever you get :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43689>
_______________________________________


More information about the Python-bugs-list mailing list