Defining *class* methods on C code
Diez B. Roggisch
deets_noospaam at web.de
Thu Feb 5 17:09:36 EST 2004
> How can I attach *class* methods to a type in C code, when I have a
> function
>
> PyObject *func(PyObject *type, PyObject *arg);
>
> with the METH_O calling convention? The type is already created, I
> cannot insert it into the tp_methods array anymore.
>
> Something like this:
>
> class X(object):
> pass
>
> def func(cls, arg):
> ....
>
> X.func = classmethod(func)
Try METH_STATIC as flag for PyMethodDef.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list