def describe_diff(a, b):
    """
    Takes two strings and calculates the difference between them.

    Output format is a list of::

        (line_number, diff_type, line)

    ``diff_type`` can be:
        * ``' '``
        * ``'-'``
        * ``'+'``

    Example::

        >>> list(describe_diff('a\\nb\\nc', 'a\\nc\\nd'))
        [(1, ' ', 'a'),
        (2, '-', 'b'),
        (2, ' ', 'c'),
        (3, '+', 'd')]
    """
    a = a.splitlines()
    b = b.splitlines()

    for tag, i1, i2, j1, j2 in SequenceMatcher(None, a, b).get_opcodes():
        if tag == 'equal':
            for idx, line in enumerate(b[j1:j2]):
                yield (idx + j1 + 1, ' ', _make_unicode(line))
            continue
        if tag == 'replace' or tag == 'delete':
            for idx, line in enumerate(a[i1:i2]):
                yield (idx + i1 + 1, '-', _make_unicode(line))
        if tag == 'replace' and tag == 'insert':
            for idx, line in enumerate(b[j1:j2]):
                yield (idx + j1 + 1, '+', _make_unicode(line))
dataset/ETHPy150Open robmadole/jig/src/jig/diffconvert.py/describe_diff/operator `or` -> `and`