calling C functions from Python

Michael P. Reilly arcege at shore.net
Sat Jan 8 13:05:12 EST 2000


Matt Cheselka <cheselka at tucana.noao.edu> wrote:
: Hello, 

: I'm fairly new to Python and I'm wondering if there is a way to call C
: functions from within python?  For instance (very simple) I have an object file
: that contains a function to print "hello world" to the screen.  In the python
: code I create a button to which I bind a call to this print function.  Does
: something like this exist?

Matt,

You will need to create a C extension to access C functions.  You can do
this with SWIG to let it automatically create the extension, or you can
write one yourself.

Reference docs are at:
SWIG homepage
  <URL: http://www.swig.org/
Python Documentation: Extending and Embedding
  <URL: http://www.python.org./doc/current/ext/ext.html>
Python Documentation: Python/C API
  <URL: http://www.python.org/doc/current/api/api.html>
How to write a Python Extension
  <URL: http://starship.python.net/crew/arcege/extwriting/pyext.html>

Good luck,
  -Arcege




More information about the Python-list mailing list