How to create an instance of a python class from C++

Bill galaxyblue63 at
Wed Mar 5 14:42:20 CET 2014

> So far, so good.  The object that was passed in was the "Derived"
> class object.  Since you presumably only want class objects to be
> passed in, you might want to check that here using PyType_Check.
    Yes. Will do.
> >         PyTypeObject *typ = class_decl->ob_type;
> In Python, you instantiate a class by calling it.  You should do the 
> same in C, using PyObject_CallFunction.  But as above, note that you
> want to call class_decl, not class_decl->ob_type.

    Of course. That works.



More information about the Python-list mailing list