diff options
Diffstat (limited to 'Doc/extending/embedding.rst')
-rw-r--r-- | Doc/extending/embedding.rst | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index e5c7da1..5c4fde8 100644 --- a/Doc/extending/embedding.rst +++ b/Doc/extending/embedding.rst @@ -223,11 +223,17 @@ Python extension. For example:: NULL, NULL, NULL, NULL }; + static PyObject* + PyInit_emb(void) + { + return PyModule_Create(&EmbModule); + } + Insert the above code just above the :cfunc:`main` function. Also, insert the -following two statements directly after :cfunc:`Py_Initialize`:: +following two statements before the call to :cfunc:`Py_Initialize`:: numargs = argc; - PyModule_Create(&EmbModule); + PyImport_AppendInittab("emb", &PyInit_emb); These two lines initialize the ``numargs`` variable, and make the :func:`emb.numargs` function accessible to the embedded Python interpreter. |