code: def capture(context, callable_, *args, **kwargs):
      
  
      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()
docs: Execute the given template def, capturing the output into
      a buffer.
  
      See the example in :ref:`namespaces_python_modules`.