[C++-sig] callbacks to python

David Abrahams dave at boost-consulting.com
Sat May 28 04:16:38 CEST 2005


David King <dking at nrao.edu> writes:

> Hi all:
>
> Can you quickly tell me how boost might support calling back from C[++] into
> python, as described in the Python C API here:
>
>      http://docs.python.org/ext/callingPython.html

Once you get ahold of a callable Python object by your favorite means,
and store it in a boost::python::object, it's as simple as calling
that object.

  void call_back(boost::python::object f)
  {
      f(3.14, "hello, world"); // or whatever
  }

HTH,
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list