[Tutor] Importing C,C++,Asm modules

Bill Burns billburns at pennswoods.net
Thu May 5 04:58:02 CEST 2005


On Wednesday 04 May 2005 4:39 am, Ali Polatel wrote:
>     Dear friends,
>     Is there a way to import C,C++ or Asm modules to python scripts?
>     If yes how?
>     Thanks and regards,

Hi Ali,

If you're asking if you can take C or C++ code and compile it in such a way
as to be able to import it into python, them the answer is yes.

Take a look at the following sites:

http://www.swig.org/
Here's a nice, easy tutorial on using SWIG:
http://www.swig.org/tutorial.html

Boost.Python
http://www.boost.org/libs/python/doc/index.html

SIP
http://www.riverbankcomputing.co.uk/sip/index.php

I noticed a Tutor post today entitled '[Tutor] Psyco (Joseph Quigley)' in 
which Max Noel mentions a tutorial on the Python web site. So do a search
there as well.

Of the above, I've only used SWIG and it was very easy to use. The hard part
was figuring out how to get six lines of C to compile without complaints,
damn those type declarations :-)

HTH

Bill



More information about the Tutor mailing list