Runs f with the result of the decorated function.

def after(f, chain=False):
    """Runs f with the result of the decorated function."""
    def decorator(g):
        @wraps(g)
        def h(*args, **kargs):
            if chain:
                return f(g(*args, **kargs))
            else:
                r = g(*args, **kargs)
                f(*args, **kargs)
                return r
        return h
    return decorator