[C++-sig] question about using a python object from C++

Shi Sherebrin shi at imaging.robarts.ca
Wed Jul 2 02:29:19 CEST 2003


hello,

I've spent a lot of time reading the Boost web pages, and I'm still 
mystified.  I have a class that I built in Python.  I want to use this 
class in C++.  From reading about Boost it seems to allow bidirectional 
operation, but I can't find a simple (or any) example of using C++ to 
access a Python object.  Could someone please point me in the right 
direction?

Further digging has led me to the "embedding Python" pages of the main 
python docs, but that seems quite complicated for C++, and I'd imagine 
simplifying that is one of the things Boost.Python does.  So is there a 
simple example somewhere of how to do this:

In Python I have defined the class "myclass", and it has methods "Init", 
"Run" & "Shutdown"

Ideally, in C++ I want to be able to do something like:

<include "myclass.h">
...
myclass obj;

obj.Init(initdata);
obj.Run(params);
obj.Shutdown();


thanks in advance for any help on this,

Shi.





More information about the Cplusplus-sig mailing list