I have heterogeneous list of int
and string
I want to store all of them in vector<string>
.
With this command:
std::string temp = boost::python::extract<std::string>(xList[i][j]);
I get this error:
TypeError: No registered converter was able to produce a C++ rvalue of type std::string from this Python object of type float
You have two choices: either get the values as
boost::python::object
and check the types and do whatever you like, or register a converter that turns numbers into strings (usingstd::to_string
presumably).You can use the instructions for "Extracting C++ Types" in the docs: