How to create (static|class)-methods from C

Iustin Pop iusty at k1024.org
Fri Dec 27 04:24:24 EST 2002


Hello to all,

I managed to create a new type from C, and have some methods
defined with using 'static PyMethodDef a[] {...}', but I don't know
how could I create a static/class method from C.

I've looked at the source file funcobject.c, and I see that
static and class methods are types in their own right, so to
create instances of them I have to have a callable PyObject.
Those instances I would have then to insert into my type's
dictionary after PyType_Ready. But how can I create (easily) from
a C function a callable PyObject? And is this the proper way to
create static/class methods?

Thanks for any advice,
Iustin Pop




More information about the Python-list mailing list