I have a C++ object (named hello) exposed in a Python extension using boost::python version 1.42. This code works :
import my_ext aaa = my_ext.hello('aaa') d = { aaa:12345 } assert aaa in d #This assertion is true, as expected assert d.has_key(aaa) #This assertion is true, as expected But if I do the same thing on the C++ side, using boost::python::dict::has_key, the is key is never found. #This Python code assert my_ext.find_key(d, aaa) //Calls this C++ code bool find_key(boost::python::dict d, const hello& key_to_find) { return d.has_key(key_to_find); } I defined the operator == like this, but it is never called. bool hello::operator == (const hello &h) const { return country == h.country; } And my boost class is exposed like this : using namespace boost::python; class_<hello>("hello", init<std::string>()) .def(self == self) ; I tried stepping through the code with gdb, but I got lost ... What am I missing ? TIA -- Guillaume
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig