tp_getattrfunc, access members that are a list

Thomas Heller theller at python.net
Mon Jun 7 16:33:08 EDT 2004


Torsten Mohr <tmohr at s.netic.de> writes:

> Hi,
>
> in the documentation and the examples that describe how to
> make the members of a new type accessible it says that
> i need to use the getattrfunc and setattrfunc if i want
> to access members that are an array.
>
> typedef struct {
>   PyObject_HEAD
>   unsigned char d[8];
> } pmod_obj;
>
> Sadly i did not find any example on how to do this.
>
> Can anybody describe me how i can access the array d[8]
> as a list?  I'd like to get AND set values in there.

I don't think you can expose them as a list, but you should look into
structmember.h, and it's PyMemberDef to expose the items separately.

Thomas





More information about the Python-list mailing list