runtime.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:gardenbot 作者: GoestaO 项目源码 文件源码
def capture(context, callable_, *args, **kwargs):
    """Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    """

    if not compat.callable(callable_):
        raise exceptions.RuntimeException(
            "capture() function expects a callable as "
            "its argument (i.e. capture(func, *args, **kwargs))"
        )
    context._push_buffer()
    try:
        callable_(*args, **kwargs)
    finally:
        buf = context._pop_buffer()
    return buf.getvalue()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号