Am 22.06.2010 19:18, schrieb Terry Reedy: > On 6/22/2010 5:44 AM, Daniel Fetchinson wrote: >>> how can i simply add new functions to module after its initialization >>> (Py_InitModule())? I'm missing something like >>> PyModule_AddCFunction(). > > in Python, for modules written in python > > import mymod > mymod.fname = somefunc #or > setattr(mymod, namestring, funcobject)
For C code, it's a more complex. You have to construct a proper C function PyObject* from a PyMethodDef* first. See Python/modsupport.c:Py_InitModule4(). Christian -- http://mail.python.org/mailman/listinfo/python-list