[C++-sig] boost.python: call python function with kwargs from c++

meiko rachimow rachimow at googlemail.com
Thu Dec 3 13:11:41 CET 2009


Hi

How can I call a function defined in a python module from c++,
if I have to give **kwargs parameter...

example.py:

def hello(**kwargs):
    for key, value in kwargs.items():
        print key, " - ",  value


c++:
using namespace boost::python;

object fun = import("example").attr("hello")
fun()

int number = 42
std::wstring name = "Möhre"

dict kwargs;
kwargs["Number"] = number;
kwargs["Name"] = name;

fun(...) ???

What should i do ?

Meiko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20091203/f7b0db6e/attachment.htm>


More information about the Cplusplus-sig mailing list