Я только начинаю играть с расширениями Python C, и мне любопытно, почему функция C, которая вызывается из Python, должна принимать 2 аргумента PyObject *и возвращать PyObject *Я написал следующее расширение "Hello World":
#include <Python.h>
static PyObject *
hello_world(PyObject *self, PyObject *noargs)
{
printf("Hello World\n");
return Py_BuildValue("");
}
// Module functions table.
static PyMethodDef
module_functions[] = {
{ "hello_world", hello_world, METH_NOARGS, "hello world method" },
{ NULL }
};
// This function is called to initialize the module.
PyMODINIT_FUNC
inittesty2(void)
{
Py_InitModule("testy2", module_functions);
}
Почему я не могу (особенно с METH _NOARGS )использовать следующий метод hello _world:
static void
hello_world()
{
printf("Hello World\n");
}
?