(original) (raw)

#include static PyObject * spam_isiter(PyObject *self, PyObject *args) { int out = 0; PyObject *obj; if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; out = PyIter_Check(obj); if (PyErr_Occurred() != NULL) { PyErr_Clear(); out = 0; } return Py_BuildValue("i", out); } static PyMethodDef SpamMethods[] = { {"isiter", spam_isiter, METH_VARARGS, "Execute a shell command."}, {NULL, NULL, 0, NULL} /* Sentinel */ }; PyMODINIT_FUNC initspam(void) { PyObject *m; m = Py_InitModule("spam", SpamMethods); if (m == NULL) return; }