Hi to all.
May be someone do class inheritance in Python/C API, I know how create
superclass/subclass. But how I can initialize superclass from subclass
initializer?

struct SuperClass {
    PyObject_HEAD;
    //...
};

struct SubClass {
    PyObject_HEAD;
    //...
};

static int SubClassInit(SubClass *self, PyObject *args, PyObject
*kwds)
{
    // how I should initialize super class?
}

PyTypeObject SuperClassType = {
   //...
};

PyTypeObject SubClassType = {
        PyObject_HEAD_INIT(NULL)
        0, /* ob_size*/
        //...
        SubClassInit, /* tp_init */
        //...
        NULL, /* tp_getset */
        &SuperClassType, /* tp_base */
        NULL, /* tp_dict */
        //...
};

Another question how I can access to superclass from subclass(I need
get access to SuperClass C struct members)?

Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to