Help needed adding attributes to a C-coded class
vincent at visualtrans.de
Sun Dec 14 18:59:39 CET 2003
How can I add an attribute to a C-coded class (..using PyClass_New()...) in
the __init__ method of that class, making it show up in "self.__dict__" on
the Python side?
IOW, when I have a class called "Screen" in a C-extension that has an
__init__ method that takes a single argument called "name" (apart from
"self" of course), how can I add this as an attribute to the class so that
it equals a "self.name = name" assigment in a pure Python class?
So far my "__init__" method looks something like:
static PyObject *
ex_Screen__init__(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "Os", &selfObject, &name))
/*now "name" becomes one of the instances attributes
exposed as instance.__dict__ on Python side..... but how?*/
Any pointers much appreciated!
More information about the Python-list