newbie writing an extention...

Michael Gilfix mgilfix at eecs.tufts.edu
Wed May 1 13:09:50 EDT 2002


  There are many ways to approach this problem. One is to use
SWIG (search google). Or, you can create your own custom bindings
(if the project is small, or the code hasn't been written yet,
this might be the way to go). Check out the documentation at:
http://www.python.org/dev/doc/devel/api/api.html.

  You'll probably want to create a new python type that corresponds
to your struct and then pass that type in to the python function as a
PyObject. The documentation offers some good examples.

                -- Mike

On Wed, May 01 @ 16:32, Daniel T. wrote:
> Assume I have the following c header:
> 
> typedef struct Type;
> int makeType(Type** t); // returns 0 if successful
> void destroyType(Type* t);
> int getValue(Type* t);
> void setValue(Type* t);
> int comapreTypes(Type* t1, Type* t2);
>    // returns -1 if t1 is less, 1 if t2 is less, or 0
> 
> IE a basic module.
> 
> How would the c file for the lib extention look? I'm esecially 
> interested in how to parse the arguments of the function.
> 
> TIA
> -- 
> http://mail.python.org/mailman/listinfo/python-list
`-> (notdanielt3)

-- 
Michael Gilfix
mgilfix at eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html





More information about the Python-list mailing list