Wrapping up a C++ class

Alex Martelli aleaxit at yahoo.com
Mon Jan 29 11:47:59 EST 2001


<warrickb at my-deja.com> wrote in message news:954496$ues$1 at nnrp1.deja.com...
> Hi,
>
> Could anyone provide me with a simple example of wrapping a simple C++
> class for use in Python (I seem to be unable to find one - I must be
> missing something) - including the details of the creation and
> destruction of the actual C++ instance?  An extra example of dealing
> with virtual methods would also be a bonus!

If you can use the Boost Python Library, you'll find excellent examples
of what you require at www.boost.org -- including creation, destruction,
and virtual methods.

If, for any reason, you can't or won't use Boost Python, then your
life may be a bit harder.  There are other C++ wrappers for the C
API's, but they may not be quite as simple to use -- I have no URL's
handy for their docs and examples.  With the bare C API, there is
no such thing as "a simple example of wrapping a simple C++ class":
you'll be re-doing manually the work that Boost Python (or other
C++/Python wrappers) implement for you.


Alex






More information about the Python-list mailing list