Guido van Rossum | 026f01a | 1996-09-06 21:16:21 +0000 | [diff] [blame] | 1 | #include "Python.h" |
| 2 | |
| 3 | static PyObject * |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 4 | ex_foo(PyObject *self, PyObject *args) |
Guido van Rossum | 026f01a | 1996-09-06 21:16:21 +0000 | [diff] [blame] | 5 | { |
| 6 | printf("Hello, world\n"); |
| 7 | Py_INCREF(Py_None); |
| 8 | return Py_None; |
| 9 | } |
| 10 | |
| 11 | static PyMethodDef example_methods[] = { |
| 12 | {"foo", ex_foo, 1, "foo() doc string"}, |
| 13 | {NULL, NULL} |
| 14 | }; |
| 15 | |
| 16 | void |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 17 | initexample(void) |
Guido van Rossum | 026f01a | 1996-09-06 21:16:21 +0000 | [diff] [blame] | 18 | { |
| 19 | Py_InitModule("example", example_methods); |
| 20 | } |