Return specialised explanations for some operators/operands

def assertrepr_compare(config, op, left, right):
    """Return specialised explanations for some operators/operands"""
    width = 80 - 15 - len(op) - 2  # 15 chars indentation, 1 space around op
    left_repr = py.io.saferepr(left, maxsize=int(width//2))
    right_repr = py.io.saferepr(right, maxsize=width-len(left_repr))

    summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr))

    issequence = lambda x: (isinstance(x, (list, tuple, Sequence)) and
                            not isinstance(x, basestring))
    istext = lambda x: isinstance(x, basestring)
    isdict = lambda x: isinstance(x, dict)
    isset = lambda x: isinstance(x, (set, frozenset))

    def isiterable(obj):
        try:
            iter(obj)
            return not istext(obj)
        except TypeError:
            return False

    verbose = config.getoption('verbose')
    explanation = None
    try:
        if op == '==':
            if istext(left) and istext(right):
                explanation = _diff_text(left, right, verbose)
            else:
                if issequence(left) and issequence(right):
                    explanation = _compare_eq_sequence(left, right, verbose)
                elif isset(left) and isset(right):
                    explanation = _compare_eq_set(left, right, verbose)
                elif isdict(left) and isdict(right):
                    explanation = _compare_eq_dict(left, right, verbose)
                if isiterable(left) and isiterable(right):
                    expl = _compare_eq_iterable(left, right, verbose)
                    if explanation is not None:
                        explanation.extend(expl)
                    else:
                        explanation = expl
        elif op == 'not in':
            if istext(left) and istext(right):
                explanation = _notin_text(left, right, verbose)
    except Exception:
        _logger.exception("dessert: representation of details failed.  "
                          "Probably an object has a faulty __repr__.")

    if not explanation:
        return None

    return [summary] + explanation