Wednesday, 19 April 2017

How to import a C file into python





I made a GUI in Python and i just wanted to know how can i import a C file into python so every time a button is clicked on my GUI, different methods in the C program will be executed. I tried the 'Python' method of importing:



sys.path.insert(0, '/home/pi/Desktop/FTPclass.py')
import FTPclass



That worked for the python file i imported, but when I do the same for my c file, it complains saying my "testinc" module doesn't exist.



Thanks for everyone help in advance.
~Neamus


Answer



To use c file according to docs you need to first compile C code and then use the compiled file in your code



here is the link.
Visit http://book.pythontips.com/en/latest/python_c_extension.html



No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...