C++ Modules for python: How to?
Diez B. Roggisch
deets at nospam.web.de
Fri Jul 6 16:06:14 EDT 2007
Robert Dailey schrieb:
> Hi,
>
> I'm interested in making a C++ library of mine usable through python.
> Python does a similar thing with Expat (the non-validating XML
> parser). I notice that with Expat, python is importing a C++ header
> file into a PY file and the interface is available to python. I've
> read through the python documentation as well as done a little bit of
> google research and I've not been able to find a tutorial of some sort
> on how to do this. Perhaps I just don't know the right words to search
> for.
>
> If anyone could lead me in the right direction (possibly an article,
> tutorial, etc) I would greatly appreciate it.
The best thing to do is to offer your C++-lib with a C-style interface.
Then you can use python's ctypes (included since python2.5) to access
the shared library.
If you insist on using C++, you can expose the lib using several
available wrapper generators. I know of three: SIP, Swig &
Boost::Python. The first I've got some very good first-hand experience.
The second is somewhat primitive IHMO. The third I never used.
Use these to google in this group, you'll find plenty of stuff.
Diez
More information about the Python-list
mailing list