[C++-sig] Parameter translation python, C++

Stefan Fleiter sf.lists at web.de
Wed Aug 13 15:32:11 CEST 2003


Hi,

when I call a boost::python method from python
with a parameter of type float and there is only
a C++ Method with a parameter of type double
I get an "unidentifiable C++ exception".

C++-Code:
--------------------------------------------------------
void pybind(db::ExtCursor& cur, int column, float value)
{
   // do something
}

BOOST_PYTHON_MODULE(_dblib)
{

     void (*bind4)(db::ExtCursor&, int, double) = &pybind;

     py::class_< db::ExtCursor, boost::noncopyable >("ExtCursor", 
py::init< db::Connection& >())
         .def("bind", bind4, "bind value to query")
}

Python-Code:
--------------------------------------------------------
self._cCursor.bind(0, 2.3) // _cCursor is db::ExtCursor


PS: I am using boost::python 1.30.

Thanks,
Stefan





More information about the Cplusplus-sig mailing list