2.2.7 More Suggestions
Remember that you can omit most of these functions, in which case you
provide
In order to learn how to implement any specific method for your new
data type, do the following: Download and unpack the Python source
distribution. Go the Objects directory, then search the
C source files for When you need to verify that an object is an instance of the type you are implementing, use the PyObject_TypeCheck function. A sample of its use might be something like the following:
if (! PyObject_TypeCheck(some_object, &MyType)) { PyErr_SetString(PyExc_TypeError, "arg #1 not a mything"); return NULL; } |