Associating a C++ class with a Python class

David LeBlanc whisper at
Fri Jun 14 23:28:58 CEST 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


David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at
> [mailto:python-list-admin at]On Behalf Of John Dunn
> Sent: Friday, June 14, 2002 13:13
> To: python-list at
> 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.
> --

More information about the Python-list mailing list