| |
| | Python Extension writing (Site not responding. Last check: 2007-10-21) |
 | | PyObject *MyCommand(self, args) PyObject *self, *args; { PyObject *result = NULL; long a, b; if (PyArg_ParseTuple(args, "ii", &a, &b)) { result = Py_BuildValue("i", a + b); } /* otherwise there is an error, * the exception already raised by PyArg_ParseTuple, and NULL is * returned. |
 | | PyObject *counter_getattr(self, attrname) PyObject *self; char *attrname; { PyObject *result = NULL; counter *object = (counter *)self; if (strcmp(attrname, "value") == 0) result = PyInt_AsLong(object->value); else PyErr_SetString(PyExc_AttributeError, attrname); return result; } /* the C setattr function should return an integer, 0 on success, -1 when an exception is raised. |
 | | When the given value is NULL, then "delattr" was called instead of "setattr". |
| starship.python.net /crew/arcege/extwriting/pyext.html (976 words) |
|