_PyObject_New / PyObject_Init / PyInstance_New / etc?
Gre7g Luterman
hafeliel at yahoo.com
Sun May 20 14:19:50 EDT 2007
> From Python, you create a Noddy object by *calling* its type. Do the same
> in C:
>
> return PyObject_CallObject((PyObject *) &NoddyType, NULL);
>
> Or any other suitable variant of PyObject_CallXXX. (I've answered this
> same question yesterday, when I was not sure about this; then I've tried
> it and it appears to be working. But I've not read any docs telling this
> is *the* right way to create an object).
Many thanks. That seems to work now.
It turns out that my previous problems stemmed from defining my type as a
static, so I was ending up with multiple copies of it and of course only one
type was getting fully initialized when the module was launched!
More information about the Python-list
mailing list