Python class method as an argument of a function in a C extension
Matimus
mccredie at gmail.com
Wed Sep 26 13:00:47 EDT 2007
More information about the Python-list mailing list
Wed Sep 26 13:00:47 EDT 2007
- Previous message (by thread): Python class method as an argument of a function in a C extension
- Next message (by thread): Python class method as an argument of a function in a C extension
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Can anybody give me an hint (or some link) on how to define > 'aCFunction' and how to call 'self.myMethod' in the C source code? A python function defined in C accepts a pointer to self and a tuple of arguments, each of which is also a PyObject. If you pass a function or method, it will be included in the tuple of arguments. I don't think there is any difference between passing a method and a function. You can call that method using functions in the `Object Protocol' section of the API, such as PyObject_Call(...). Here is an example from the Python documentation: http://docs.python.org/ext/callingPython.html The first part shows how to get a function as an argument. The following bits of code show how to actually call that function.The example uses PyEval_CallObject, which I can't find documentation to. I'm not sure if it even exists (it may be a documentation error). But from the example it seems to work exactly the same as PyObject_CallObject. Matt
- Previous message (by thread): Python class method as an argument of a function in a C extension
- Next message (by thread): Python class method as an argument of a function in a C extension
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list