Serpent Addiction

Friday, November 11, 2005

Success with SWIG

It bothered me yesterday that I didn't get a Bluetooth server running with Python, so I had to go back to SWIG. The Pyrex framework is probably better for major projects, but SWIG wins out for write-once applications that won't require a lot of maintenance.

My swig file, pyobexserver.i:

%module pyobexserver
%{
#include "openobex/obex.h"
%}
int get_my_file(char *outfile);

From the Python interpreter:

>>> from pyobexserver import get_my_file
>>> get_my_file('/home/jbauer/nokia/files')
Waiting for connection...


What could be easier? From downloading SWIG to running a functional program: 30 minutes. I love Python.

0 Comments:

Post a Comment

<< Home