Example (cont)Step two: package into a module/* Module 'spam' #include "Python.h" extern int gcd(int, int); /* Wrapper for gcd */ static PyObject * py_gcd(PyObject *self, PyObject *args) { ... blah ... } /* Method table */ static PyMethodDef spammethods[] = { {"gcd", py_gcd, METH_VARARGS}, { NULL, NULL} }; /* Module initialization */ void initspam() { Py_InitModule("spam",spammethods); } |
<<< | O'Reilly OSCON 2000, Advanced Python Programming, Slide 121 July 17, 2000, beazley@cs.uchicago.edu |
>>> |