Adding a 'struct' into new python type

Lakshmipathi.G lakshmipathi.g at gmail.com
Sat Mar 7 04:15:41 EST 2015


Hi,

I'm following this example :
http://nedbatchelder.com/text/whirlext.html#h_making_a_type and trying
to add
new data into 'CountDict' type

Adding a simple 'char' works well.

typedef struct {
   PyObject_HEAD
   PyObject * dict;
   int count;
   char c;  //add this and placed an entry into PyMemberDef as T_CHAR.
} CountDict;

I can access  'c' from python code,no issues so far.

Now I want to added 'struct type' into this 'CountDict' type.
struct test {
int x;
};

typedef struct {
   PyObject_HEAD
   PyObject * dict;
   int count;
   char c;
   struct test t1; //?? how to add this
} CountDict;

How to do achieve this? (Due to legacy code dependency, I can't use
ctype/cpython etc).
thanks for any help/pointers.



----
Cheers,
Lakshmipathi.G
FOSS Programmer.
www.giis.co.in/readme.html



More information about the Python-list mailing list