I have a question about managing python objects. I have a base class implemented in c++, which I use in python.
From python I inherit that class. And the I try to use the python instance from c++, like this.
//This class has a function which is registered in python. I want to //be able to register python instances with this class class AnotherClass { void registerobject(const std::string & name, MyBaseClass * a) { v.push_back(a); } }; //Interface class, which I inherit in python class MyBaseClass { virtual const std::string getData(Object * o) const = 0; };
From python:
class MyPyClass(MyBaseClass): def __init__(self): MyBaseClass.__init__(self) def getData(self, o): return "hello" My question is. In order to register that class, namely, MyPyClass(which is a python class): can I do it through registerobject? Or should I implement something like this?: class AnotherClass { void registerobject(const std::string & name, python::object & o) { MyBaseClass * m = extract<MyBaseClass>(o); v.push_back(m); } }; In all two cases I get error_already_set exception when I try to execute the registerobject function and don't know why.