I am passing a list of (mostly) floats to a module in boost python, some elements are None objects. In C ++ code, I retrieve the floats as follows:
for(i=0;i<boost::python::len(list) - window_len + 1;i++) { double value = boost::python::extract<double>(list[i]); }
This is clearly problematic when the list [i] points to a python None object. As such, I wrote something like this:
for(i=0;i<boost::python::len(list) - window_len + 1;i++) { if(list[i] == NULL) continue; double value = boost::python::extract<double>(list[i]); }
and
for(i=0;i<boost::python::len(list) - window_len + 1;i++) { if(list[i] == boost::python::api::object()) continue; double value = boost::python::extract<double>(list[i]); }
because obviously boost :: python :: api :: object () is None. However, none of them work. How can I check this list [i] in a python None object?
source share