2

I have some code written in c that i want to call from python. Is there a way to do this. I looked at several documentations but they look quite vague. Can some one give me some specific steps please

Edit:

I wrote below dll called djj.dll it has a file called try.cpp with following code

#include<stdio.h>

int print(){

return 4;

}

Now, i build this dll and go to python idle.

I type print windll.djj.print . It gives syntax error .WHY??

Programmer
  • 6,565
  • 25
  • 78
  • 125
  • http://stackoverflow.com/questions/145270/calling-c-c-from-python – Mat Sep 17 '11 at 15:25
  • The easiest way is with ctypes. The ctypes tutorial is excellent. – David Heffernan Sep 17 '11 at 15:27
  • I don't think this is a duplicate. `print` is a reserved word in Python 2.X (Python 3 changes it to an ordinary predefined function). What happens if you change the name of your C function from `print` to, say, `Print`? – Keith Thompson Sep 17 '11 at 19:28

0 Answers0