C wrapper

Sheldon shejo284 at gmail.com
Tue Nov 7 21:27:00 CET 2006


Robert Kern skrev:

> Sheldon wrote:
>
> > This function is there and is called init_mymodule() but I have other
> > functions that are not static.
>
> Is the module's name "_mymodule"? Or is it "mymodule"?
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco

Here is the file/module name: _msgpps_functions.c
Here is the initfunction:

PyMODINIT_FUNC init_msgpps_functions(void) {
  PyObject* m;
  m=Py_InitModule("_msgpps_functions",_msgpps_functionsMethods);
  ErrorObject = PyString_FromString("_msgpps_functions.error");
  if(ErrorObject == NULL ||						\
     PyDict_SetItemString(PyModule_GetDict(m),"error",ErrorObject)!=0)
{
    Py_FatalError("Can't define _msgpps_functions.error");
    import_array();
  }     /*  access to Numeric PyArray functions */
}


I have not main() function in the file. Instead the main function is
called the same name:

static PyObject* _msgpps_functions(PyObject* self, PyObject* args)

Now I am new at this and I have been reading anything I can find. The
only thing that is out of place is the part which I didn't include:

    /* Initialize the Python interpreter.  Required. */
    Py_Initialize();

    /* Add a static module */
    initspam();
because I still don't understand this part.

/sheldon




More information about the Python-list mailing list