import c-library into python

Roger Hansen rogerha at ifi.uio.no
Tue May 16 14:11:34 CEST 2000


* Tamer Fahmy
> 
> Haegges wrote:
> > 
> > Hello,
> > I have a library (and the source) written in c. How can I import
> > these lib into python? So, that I can access the c-functions, if
> > possible without changing many c-code!
> 
> Hi!
> 
> There are actually 2 possibilities I know of:
> 1. write a wrapper Python module to your C library.
>    The document on http://www.python.org/doc/current/ext/ext.html
>    should provide you with information how to do this.

This is a good solution if you only have to wrap a few functions.
However if it's a library I would suggest SWIG 
<Url: http://swig.sourceforge.net/ >
since wrapping lots of functions are boring and error-prone. But you
should look at the "Extending ..." document above to get the feeling
of things. 


HTH,
Roger



More information about the Python-list mailing list