How to access nested structural members from python

abarun22 at gmail.com abarun22 at gmail.com
Thu Nov 29 06:43:01 CET 2007


Hi
I would like to know if there are any ways to access the members of a
nested structure inside python. I use SWIG as interface for C. My
structure comes as follows.
struct SA{
int nb_dep, max_dep
SB *b
}

struct SB{
int id[10], node, kg;
double dep[3];
}

I have written a C helper function like this to access the internal
members of the structure SB.
SB get_sb(SB *b, int index){
     return(b[index]);
}
>From python i call like this for example:
>>modname.get_sb(sb, i).node     where i=1,2....N

What i would like to know is that any other way to access the internal
pieces of nested structure. Any ideas in this regard are most welcome.



More information about the Python-list mailing list