Passing object arguments to C functions exposed to Python layer

Geoffrey Wilfart wilfartg at hotmail.com
Tue Dec 18 06:52:17 EST 2001


Hello

I have created a new object type as described in Python documentation,
that I use as a wrapper for a C structure.
The object is like :
typedef struct {
  PyObject_HEAD
  my_c_struct my_struct;
} MyObject

I have then a "constructor" function, that creates a new MyObject and
initializes  the C structure. It returns the newly created object.
I use it from Python as: 

my_obj = open()

Then, I would like to "close" the object, i.e. delete the C structure,
and then deallocate it. However, if I use a call like:

close(my_obj), the "args" value is not "my_obj". 

Could someone tell me what I should do in this case ?

Thanks a lot.
Geoffrey



More information about the Python-list mailing list