Wrapper classes: creating a python wrapper for a C project
1 answer
You should try a wrapper generator like SWIG . Writing glue code by hand is repetitive and boring. Why don't you make the computer the easy parts for you?
SWIG will take the source files and the (minimal) interface specification. It will create Python proxy classes and C / C ++ code. You compile your C / C ++ code into a Python Extension Library and then use it just like you would in a pure-Python library. Under the hood, SWIG proxy classes generate a descriptor that converts Python types to / from calls to original C functions.
As an added bonus, wrapper generators (including SWIG) can usually create bindings for different high-level languages with little or no extra effort on your part.
+4
source to share