Calling a "raw" python function from C++

Harmon Nine hnine at isis.vanderbilt.edu
Tue Feb 2 17:38:00 EST 2010


Hello.
 
I've been crawling the web for an answer to this one, but have come up
empty.
 
We can currently only use Boost 1.36 for our project, i.e. we are having
problems using later versions of Boost.  We are using Boost.Python to
interface with Cheetah.
 
Problem:
In Boost 1.36, how do you call a "raw" method of a python class from
C++?  In particular, what C++ code is needed to call a "raw
constructor", i.e. a constructor that can take an arbitrary number of
positional and keyword arguments by using *args, **kwargs?
 
For instance, this is defined in a ".py" file.
 
class Gain:
   def __init__( self, *args, **kwargs ):
   ...
 
 
In C++ we have (where "gainClass" is the Gain class above referenced
from C++):
-----
namespace bp = boost::python;
 
bp::object gainObject = gainClass( /* what goes here to call the above
Gain constructor? */ );
-----
 
Passing a tuple and a dict doesn't work.  I wish we could use the most
recent version of Boost, since in this you can just do this:
-----
bp::object gainObject = gainClass( *bp::tuple(), **bp::dict() );
-----
But this is not available in Boost 1.36
 
TIA
-- Harmon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100202/d09804fc/attachment.html>


More information about the Python-list mailing list