How do I pass structures using a C extension?

Jaime Wyant programmer.py at gmail.com
Mon Mar 14 08:33:54 EST 2005


You need to check out swig.  It is the *only* way to setup a `c'
library for use with python.

http://www.swig.org/

jw


On 14 Mar 2005 05:25:03 -0800, timothy.williams at nvl.army.mil
<timothy.williams at nvl.army.mil> wrote:
> Hi.
> 
> I trying to write an extension module to call some C libraries so I can
> use them in Python. Several of the library functions pass pointers to
> structures as arguments. I was thinking that I could create a class for
> each structure, but I'm not sure how to get the data back and forth.
> The example the "Extending and Embedding the Python Interpreter" manual
> has examples of passing strings and ints using
> PyArg_ParseTupleAndKeywords(), but it's not clear to me if I can even
> pass structs around like this.
> 
> I'm just learning how to do extensions, so any help is greatly
> appreciated.
> 
> Thanks.
> 
> ----
> Tim Williams
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list