I have my extension for Python written in C. Currently I need to process in a function of my extension objects of a type declared in some external pure python module (Say, its name is ext_module
). First of all I need to ensure that input object type corresponds some class from ext_module
. How can I implement this?
Some additional code:
static PyObject * extensionFunction( PyObject* self, PyObject *args ) {
const char *inputString = NULL;
PyObject *inputList = NULL;
if ( 0 == PyArg_ParseTuple( args, "sO", &inputString, &inputList ) ) {
return NULL;
}
if ( 0 != PyList_Check( inputList ) ) {
// here I need to check whether the list items are instances of ext_module.ExtClass
} else {
PyErr_SetString( PyExc_TypeError, "extensionFunction: expected list" );
return NULL;
}
// process arguments
Py_RETURN_NONE;
}
Actually I can just try to call the expected methods and get an exception NotImplementedError
, but I'm not sure if this is correct approach.