extending python

A

Ajay

hi!

i have written simple C file and am now trying to call it from Python
the file is pasted below.
I can compile it to testdll.dll but when i call it from Python, i get an
import error: No module named testdll

what am i doing wrong

thanks

cheers


#include <Python.h>

static PyObject*
test_dll(PyObject *self, PyObject *args)
{
char *command;
int sts;

if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
sts = 5;
return Py_BuildValue("i", sts);
}

static PyMethodDef testdllMethods[] = {
{"system", test_dll, METH_VARARGS, "test a dll."},
{NULL, NULL, 0, NULL}
};

PyMODINIT_FUNC
inittestdll(void)
{
(void) Py_InitModule("testdll", testdllMethods);
}
 
M

Michael Hudson

Ajay said:
hi!

i have written simple C file and am now trying to call it from Python
the file is pasted below.
I can compile it to testdll.dll but when i call it from Python, i get an
import error: No module named testdll

How are you compiling it? Where is the DLL?

Cheers,
mwh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top