[Python-Dev] Calling base class methods from C

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 22 04:54:26 CET 2007


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_CallFunctionObjArgs(meth, self, x, NULL)
plus appropriate error checking.
-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	 | Carpe post meridiem! 	 |
Christchurch, New Zealand	 | (I'm not a morning person.) |
greg.ewing at canterbury.ac.nz	 +--------------------------------------+


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /