8

I've been following some code examples on how to build a C module for Python, however it seems like Py_InitModule isn't defined anywhere.

Most sources say it's within the modsupport.h file, but the macro isn't defined there.

I'm using the includes given by the Win32 binaries download, and everything seems in check.

Any suggestions?

1
  • I think I've noticed the issue, is that Py_InitModule seems to be gone or deprecated, see link Commented May 2, 2012 at 18:14

1 Answer 1

5

Works for me on 2.7.2, Python 2 or 3? For example, for a module called Example:
Python 2:

/* Module entry point Python 2 */

PyMODINIT_FUNC initExample(void)
{
    (void) Py_InitModule("Example", ExampleMethods);
}

Python 3:

/* Module entry point Python 3 */

PyMODINIT_FUNC PyInit_Example(void)
{
    return PyModule_Create(&Example_module);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.