passing a C struct to python

Rajarshi Guha rajarshi at presidency.com
Tue Apr 22 13:56:48 EDT 2003


Hi,
  I've recently looked into calling some Python functions from my C code.
I've worked out the ways of calling a Python function
(PyObject_CallMethodObjArgs etc). However these are OK if I want to pass
a list, tuple, string etc.

However in some cases I might want to pass  an 'object' (which would be a
C struct) to the Python function. Alternatively, the Python function
might require me to pass an instance of some class. Am I correct in
thinking that these two problems are equivilant?

And my question is: what do I need to do to pass structs/classes etc? I
tried looking for pointers in the Embedding section of the Python manual,
but I could'nt really find anything :(

Any pointers would be appreciated

Thanks,




More information about the Python-list mailing list