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

Jürgen Gmach report at bugs.python.org
Sat Apr 3 04:27:22 EDT 2021


Jürgen Gmach <juergen.gmach at googlemail.com> added the comment:

First I need to apologize for not providing more info already when I created the issue.

Initially, I did not even plan to create an issue, and thought the PR with the context of the current documentation would be sufficient information.

Thanks for taking your time anyway!

Also, thanks to Tim for explaining the meaning of the question mark in detail. When I read the documentation, I also had to pause a moment to understand the sentence. But I agree with Tim, it is hard to explain it better without getting much more verbose.

My initial reason to read (and then to update) the documentation was an output of pytest, which left me puzzled.

E           AssertionError: assert 'ROOT: No tox...ith_no_t0/p\n' == 'ROOT: No tox..._with_no_t0/p'
E             Skipping 136 identical leading characters in diff, use -v to show
E             - ith_no_t0/p
E             + ith_no_t0/p
E             ?            +

Here is the screenshot and some discussion:
https://twitter.com/jugmac00/status/1377317886419738624

Using a similar snippet as Tim, here is a minimal example:

for L in d.compare(["abcdefghijkl"], ["abcdefghijkl\n"]):
    print(L)

- abcdefghijkl
+ abcdefghijkl

?             +


Usually, the output is pretty obvious most of the time, so I never actually noticed the question mark - except when whitespace characters are involved.

I was then told that pytest uses difflib, and I was kindly pointed to the Python documentation.

As only the tab character was listed, I thought it would be a good idea to add the other whitespace characters as well.

After Tim's explanation, I see, that tabs could be especially confusing, while all whitespace characters are on a normal level of confusing :-), especially at the end of the diff.

I certainly won't forget what I learned, but maybe my proposal helps one fellow Python user or another.

----------

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


More information about the Python-bugs-list mailing list