Extending Python with modules written in C
Using C (or C++) to create Python modules is really quite simple, providing you know a little C of course. I recently had to do some work around getting a bunch of legacy C code talking to a newer system and thought I’d post a nice simple example of how the Python extensions work.
This code gives you a single method “do()” that will print the output of a command, passed to it as a string, to stdout and return the exit code as a python int.