import pprint


def log_output(f):
    """
    Make a function write its input when called and output when finished.

    >>> @log_output
    ... def test(x, *ys, **kws):
    ...     return kws.get("c",0)+sum(x*y for y in ys)
    >>> test(2, 3, 4, c=1) == 1+2*3+2*4
    test(2, 3, 4, {"c": 1})
    test(2, 3, 4, {"c": 1}) = 15
    True
    """
    def g(*args, **kws):
        call = f.__name__ + pprint.pformat(args + (kws, ))
        print(call)
        res = f(*args, **kws)
        print(call + " = " + pprint.pformat(res))
        return res
    return g