def stack(*wrappers):
    """
    Stack some senders or receivers for ease of wrapping.

    ``stack(x, y, z)`` will return a factory usable as a sender or receiver
    factory which will, when called with a transport or sender as an argument,
    return ``x(y(z(argument)))``.
    """
    if not wrappers:
        raise TypeError('at least one argument is required')
    def factory(arg):
        ret = wrappers[-1](arg)
        for wrapper in wrappers[-2::-1]:
            ret = wrapper(ret)
        return ret
    return factory