Suppose I have two python boost modules that are defined as follows. Module A:
class SomeClass { public: SomeClass() {} ~SomeClass() {} }; BOOST_PYTHON_MODULE(A) { class_<SomeClass>("SomeClass"); }
And module B:
class AnotherClass { public: AnotherClass() {} ~AnotherClass() {} void func(SomeClass& sp) {} }; BOOST_PYTHON_MODULE(B) { class_<AnotherClass>("AnotherClass") .def("func", &AnotherClass::func) ; }
Module B has a dependency on module A (i.e. uses SomeClass from module A). Now I am running the following python script:
import A import B obj1 = A.SomeClass() obj2 = B.AnotherClass() obj2.func(obj1)
I get the following error:
Traceback (most recent call last): File "C:\bladiebla\script.py", line 8, in <module> obj2.func(obj1) ArgumentError: Python argument types in AnotherClass.func(AnotherClass, SomeClass) did not match C++ signature: func(class AnotherClass {lvalue}, class SomeClass)
Python does not seem to automatically translate classes between modules. Does anyone have an idea how to solve this?
c ++ python boost
Arjan
source share