C wrapper

Gabriel Genellina gagsl-py at yahoo.com.ar
Tue Nov 7 15:43:13 EST 2006


At Tuesday 7/11/2006 17:27, Sheldon wrote:

>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.

Are you *extending* Python with a new module written in C (you should 
be using the first part),
or *embedding* python inside your application, mainly written in C 
(you would use something like the last code).


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list