#include "noddy.h" void Noddy_dealloc(NoddyObject* self) { self->ob_type->tp_free((PyObject*)self); } PyObject *Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { NoddyObject *self; self = (NoddyObject *)type->tp_alloc(type, 0); return (PyObject *)self; } int Noddy_init(NoddyObject *self, PyObject *args, PyObject *kwds) { return 0; } PyObject *Noddy_testNoddy(NoddyObject *self, PyObject *args, PyObject *kwds) { int ok; PyObject *object; ok = PyArg_ParseTuple(args, "O!", &NoddyType, &object); if (ok) { ok = PyObject_TypeCheck(object, &NoddyType); printf("object is NoddyType? %d\n", ok); } else { printf("This was not a noddy type\n"); } Py_INCREF(Py_None); return Py_None; } void Other_dealloc(OtherObject* self) { self->ob_type->tp_free((PyObject*) self); } PyObject *Other_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { OtherObject *self; self = (OtherObject *)type->tp_alloc(type, 0); return (PyObject *)self; } int Other_init(OtherObject *self, PyObject *args, PyObject *kwds) { return 0; } PyMODINIT_FUNC initnoddy(void) { PyObject* m; if (PyType_Ready(&NoddyType) < 0) return; if (PyType_Ready(&OtherType) < 0) return; m = Py_InitModule3("noddy", module_methods, "Example module that creates an extension type."); if (m == NULL) return; Py_INCREF(&NoddyType); PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType); Py_INCREF(&OtherType); PyModule_AddObject(m, "Other", (PyObject *)&OtherType); }