import c-library into python

Tamer Fahmy tamer at tammura.at
Tue May 16 06:52:23 EDT 2000


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.

2. write a C program, that uses your library in all needed aspects
   and call it with os.popen() with the parameters provided you need.

I would consider number 2 a rude hack but maybe it is quicker to do. ;)


Never-be-rude-to-an-arab-ly y'rs,
  Tamer.

--
  -////-   | Tamer FAHMY, cs student at the univ. of technology Vienna
 --o o --  |                    irc, fics: tuhtah
--- <  --- |    web:http://www.tammura.at/   mailto:tamer at tammura.at
 -  v   -  | Support bacteria -- it's the only culture some people have!



More information about the Python-list mailing list