[capi-sig] Assigning values to functions from C

Campbell Barton cbarton at metavr.com
Tue Sep 4 02:16:27 CEST 2007


Hi, I need to assign a value to a function (PyCFunction) from the C apy

The python equivalent is...
---
def foo(): pass
foo.Value = 10
---

Iv looked a fair bit in python source code and cant see how this is 
possible...


The PyCFunction struct looks like this...


typedef struct {
     PyObject_HEAD
     PyMethodDef *m_ml; /* Description of the C function to call */
     PyObject    *m_self; /* Passed as 'self' arg to the C func, can be 
NULL */
     PyObject    *m_module; /* The __module__ attribute, can be anything */
} PyCFunctionObject;


m_ml cant be used, m_module looks like its for internal use only, so if 
this is possible in C, its peobably stored in *m_self,

Anyone know a solution for this?

- Cam



More information about the capi-sig mailing list