Python and C with ctypes
Calling C code from Python is very simple using ctypes. Here is a very simple example to get you started and to serve as a reminder for me!
Let's say you have this C file, defining 3 functions:
foowhich prints something to
barwhich returns and
bazwhich takes a parameter and returns a value.
First, you want to compile this C file into a shared object. Here is a
Makefile to do just this: simple type
make all and you're done.
Finally, you can call these C functions from Python using ctypes:
Obviously, there is much more to it and things get more complicated soon, but, as you can see, for simple tasks like this using ctypes is pretty straitforward.