0

I want to call a .C or .O file from my python script and execute any of the C program function. How can I write my script to call a function in C?

G Naveen
  • 1
  • 1
  • 2
    You can't "call" a `.c` or `.o` file. They aren't executable files. A `.c` file needs to be compiled, and a `.o` file needs to be linked before you have an executable. Once you have an executable, have a read through Python's [subprocess handling functions](https://docs.python.org/2/library/subprocess.html#module-subprocess). – lurker Mar 04 '16 at 12:25
  • @Selcut Not sure how this was marked as a duplicate. The alleged duplicate question is asking how to call a C/C++ library function from Python, which is a perfectly reasonable thing to do. This particular question is asking how to call a `.c` or `.o` file. Although it might lead to the same question, it isn't the same question in its current form. – lurker Mar 04 '16 at 12:28
  • 2
    @lurker True, but you can call functions in a .c file (which, if you read the question, is what the OP is trying to do), by either writing a Python extension or by using e.g. ctypes to load a shared library. – Jonathon Reinhart Mar 04 '16 at 12:29
  • Python is not a scripting but a programming language. – too honest for this site Mar 04 '16 at 14:07

0 Answers0