Hello,
I have a small question about static variable and TypeObjects. I use the API C to wrap a c++ object (let's call it Acpp) that has a static variable called x. Let's call my TypeObject A_Object :
typedef struct {
PyObject_HEAD
Acpp* a;
} A_Object;
The TypeObject is attached to my python module "myMod" as "A". I have defined getter and setters (tp_getset) so that I can access and modify the static variable of Acpp from python :
>>> import myMod
>>> myA1 = myMod.A(some args...)
>>> myA1.x = 34 # using the setter to set the static variable of Acpp
>>> myA2 = myMod.A(some other args...)
>>> print myA2.x
34
>>> # Ok it works !
This solution works but it's not really "clean". I would like to access the static variable in python by using the TypeObject and not the instances :
>>> import myMod
>>> myMod.A.x = 34 # what I wish...
Does anybody have an idea to help me ?
Thanks in advance.