function pointer

Andrew H. Chatham andrew.spambgone.chatham at
Mon Dec 11 21:43:52 EST 2000

You could use a CObject, which is what I've done before, though it has
limitations. A CObject is really just a Python object that holds a C pointer.
See . Of course, doing it this
way, you'd have to already know what kind of arguments and return values the
function takes and there's also the possibility that someone could pass a bad
pointer if they had a CObject from another module, since you cast it to a "void
*" to store and retrieve it from the CObject. So if you already know what kind
of function it will be a pointer to and don't expect people to go out of their
way to break your module, a CObject would be a good choice.


On Mon, 11 Dec 2000 17:51:01 -0800, Curtis Jensen <cjensen at>
>Is there a way to pass a pointer to a function from a module in a shared
>library?  e.g. We have a compiled C module that has the function "foo" in it
>(foo is not wrapped, it's straight C code).  We have another copiled C module.
>We want "foo" to be passed in to a function in the second module as a
>paramater.  Is this possible?  Hope this makes sence.
>-- Curtis Jensen cjensen at
>FAX (425) 740-1451

Andrew Chatham
Duke University '02
andrew.chatham at

More information about the Python-list mailing list