[capi-sig] Create instance given its type

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Jan 8 17:45:02 CET 2010


Hello

I want to create an instance given its type object. I expected that calling the type would be enough, something like this:

obj = (MyFooObject *) PyObject_CallFunctionObjArgs(&MyFooType, other, arguments, NULL)

but it doesn't work (nor even compiles, I think). So this is what I'm doing now:

obj = (MyFooObject *) PyObject_CallMethod((PyObject *)&PyType_Type, "__call__", "OOO", &MyFooType, other, arguments);

where MyFooType is a PyTypeObject struct. Ok, it works, but I'm pretty sure there is a more direct way - but how?

Thanks,
-- 
Gabriel Genellina


      Yahoo! Cocina

Encontra las mejores recetas con Yahoo! Cocina.


http://ar.mujer.yahoo.com/cocina/


More information about the capi-sig mailing list