Hello SO :)
I am writing C extensions, and I'd like to specify for my users the signature of my methods. Let's throw in some code :)
static PyObject* foo(PyObject *self, PyObject *args) {
/* blabla [...] */
}
PyDoc_STRVAR(
foo_doc,
"Great example function\n"
"Arguments: (timeout, flags=None)\n"
"Doc blahblah doc doc doc.");
static PyMethodDef methods[] = {
{"foo", foo, METH_VARARGS, foo_doc},
{NULL},
};
PyMODINIT_FUNC init_myexample(void) {
(void) Py_InitModule3("_myexample", methods, "a simple example module");
}
Now if (after building it...) I load the module and look at its help:
>>> import _myexample
>>> help(_myexample)
I will get:
Help on module _myexample:
NAME
_myexample - a simple example module
FILE
/path/to/module/_myexample.so
FUNCTIONS
foo(...)
Great example function
Arguments: (timeout, flags=None)
Doc blahblah doc doc doc.
I would like to be even more specific and be able to replace foo(...) by foo(timeout, flags=None)
Can I do this? How? :)
Thanks!