> class List(list):
> def append(self, x):
> print x
> List.append(self, x) # What is the C equivalent of this call?
Always literally what you write in Python (assuming you meant
list.append):
PyObject_CallMethod(PyList_Type, "append", "OO", self, x);
HTH,
Martin
_
Raymond Hettinger wrote:
> class List(list):
> def append(self, x):
> print x
> List.append(self, x) # What is the C equivalent of this call?
Something like
PyObject *meth, *result;
meth = PyObject_GetAttrString(PyList_Type, "append")
result = PyObject_CallFunctionObj
The xxsubtype.c module gives an example of calling a parent method if it is in
a slot:
static int
spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds)
{
if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
return -1;
self->state = 0;
return 0;
}
How you c