Associating a C++ class with a Python class

David LeBlanc whisper at oz.net
Fri Jun 14 17:28:58 EDT 2002


Try the Boost Python library that does all this and more - you can write
python classes callable from C++ and vice versa. The author says the latest
and greatest (version 2) is best obtained from CVS if you're starting a new
project.

www.boost.org

HTH,

David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of John Dunn
> Sent: Friday, June 14, 2002 13:13
> To: python-list at python.org
> Subject: Associating a C++ class with a Python class
>
>
> I would like to add a new class type to my embedded python engine and
> I would like this class to wrap an exisiting C++ class instance. All
> of the examples I have found are more 'c implementation' than 'c
> wrappers', meaning that the python instance is not associated with an
> different c++ class. The methods of the python class will just be
> straight calls through to the C++ class.
>
> These classes will only be created from C, so I am basically looking
> for a way to stuff a pointer to my C++ class into the python object. I
> guess I could have a map of PyObject->C++ class, but I was hoping
> there was a cleaner way to accompish this task. Is there a standard
> way to do this? Am I missing something obvious?
>
> Thanks-
>
> John
> --
> John Dunn
> Peak Audio, a division of Cirrus Logic, Inc.
> http://www.peakaudio.com
> --
> http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list