Re: [Python-Dev] Calling base class methods from C

2007-03-21 Thread Martin v. Löwis
> 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 _

Re: [Python-Dev] Calling base class methods from C

2007-03-21 Thread Greg Ewing
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

[Python-Dev] Calling base class methods from C

2007-03-21 Thread Raymond Hettinger
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