> > > For ElementWrap::get_float, try: > > > float get_float() { return this->get_override("get_float")(); } > > > > > > Binding to Python of that function should then be: > > > .def("get_float", pure_virtual(&Element::get_float)) > > > > > > See also: > > > http://www.boost.org/doc/libs/1_57_0/libs/python/doc/tutorial/doc/ > > > html/python/exposing.html#python.class_virtual_functions > > > > > > With regards, > > > > > > Paul > > > > Doesn't solve this problem: > > I confirm what Holger said. Paul's reply doesn't solve the problem. > In fact, if I change the ElementWrap::get_float to: > virtual float get_float() { return this->get_override("get_float")(); } > > I get in python: > Traceback (most recent call last): > File "m2.py", line 18, in <module> > print (element.get_float()) > TypeError: 'NoneType' object is not callable
Is your element object actually a SubElement instance or a m1.Element instance here? You should normally get this only when calling the get_float method of an m1.Element instance. This is basically a call to a pure virtual method which is really only possible because the original C++ element class is represented to Python by the derived ElementWrap class, which overrides the pure virtual to make callbacks from C++ to Python possible. I put the boost::python::detail::pure_virtual_called(); line into my example code to have a nicer error message for this case. No step closer to solving your actual problem, though... Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig