Wrappers serve as „glue“ languages
between languages.
We need them to return results in a
Python friendly form.
// factorial.c
int fact(int n) {
if (n <= 1)
return 1;
else
return n*fact(n-1);
}
PyObject *wrap_fact(PyObject *self,
PyObject *args) {
int n, result;
if (!PyArg_ParseTuple(args, "i:fact", &n))
return NULL;
result = fact(n);
return Py_BuildValue("i", result);
}