Chris <[EMAIL PROTECTED]> writes: >> descr = GetAttrString(cls,"varname"); >> offset = descr->d_member->offset; >> slotvar = (PyObject*)(((char*)obj)+offset) > > Unfortunately, I am inexperienced at this kind of thing, so I wasn't > able to get something working. Maybe someone could tell me what's > wrong with the code below (it gives the error "'struct _object' has no > member named 'd_member'")?
You are getting that error because Carl forgot to cast the descriptor to the appropriate C type, in this case PyMemberDescrObject. The last line is also incorrect, I think. Try something like this: PyObject *descr = PyObject_GetAttrString(x,"attr_one"); int offset = ((PyMemberDescrObject *) descr)->d_member->offset; PyObject *slotvar = *(PyObject **)(((char *) obj) + offset); -- http://mail.python.org/mailman/listinfo/python-list