Creating a Python script 'interface' to c/c++ module

Makhno mak at
Tue Mar 7 16:44:19 CET 2000

My problem is difficult to explain...
I've written a module for Perl in C/C++, but user's so not call the C
functions directly, there is a level of Perl 'wrapping' it that does various
checks (as well as providing an OO interface). Having written the bulk of
the module as language-independant as possible, the time has come to port it
to Python.

Unfortuanately, I can't seem to provide the Python wrapper, the way the
modules work does not seem to let me. For example, I want to call a C
function called my_func(). With Perl I would use the hierarchy:
Users code->Perl wrapper->C wrapper (XS file)->C function
with Python, I can't seem to include the second step, only
Users code->C wrapper->C function

So calling my_module.my_func() in Python, calls C code directly, there is no
chance of executing any Python inbetween.
The question is how do I get some Python code in there? The only way I can
think of is writing a Python module which acts as a wrapper for the C
module, which doesn't seem like the best way.

More information about the Python-list mailing list