Newbie question: importing module from C

nick ngiff at
Fri Nov 28 05:41:35 CET 2003

I'm trying to load the email.Message module from C and can't figure
out what I'm doing wrong.  What's wrong with the following code?

PyObject *pMessage;

pMessage = PyImport_ImportModule("email.Message");

if (pMessage == NULL) {
    printf("Null module\n");

I know my environment is set up correctly because if I change
"email.Message" to "email", then I can successfully load the email
package.  From the email package, I can then get the dictionary and
see the reference to the "Message", but don't know how to load it.

Ultimately, what I want to do is instantiate an email.Message, fill it
in, then send it off to the Python environment.

I'm using Python 2.3.2 on Red Hat 9.0

thanks in advance,

More information about the Python-list mailing list