[C++-sig] a question about embedding python in c++

David Toneian david.toneian at gmail.com
Tue Oct 31 20:07:13 CET 2006


Thank you very much :)

On 10/31/06, Stefan Seefeld <seefeld at sympatico.ca> wrote:
> David Toneian wrote:
> > do i have to pass the instance to python and retrieve it again after
> > script execution to make the changes take effect?
>
> Yes, you can pass the instance by injecting it into the environment
> (the global dictionary with which you then call the script). Any
> calls on that from within the script will directly manipulate the
> wrapped C++ instance. But details depend on how to export the class'
> API via boost::python::class_<>.
>
> > for example, is it going to be like:
> > givePythonThatInstancePlease(&someInstance);
> > executeARandomScript();
> > someInstance=getTheInstanceBackAgain();
> >
> > or is the last line not needed because python will have direct access
> > to the instance?
>
> Yes, precisely. The instance will be manipulated in-situ. There is no
> copying involved.
>
> > oh, and sorry that i'm writing only pseudo-code, which may be quite
> > far from what the real approach with boost.python will look like. i
> > just didn't want to study the library functions and classes before i
> > was sure it would be useful to me :)
>
> Understood.
>
> Good luck !
>
>                 Stefan
>
> --
>
>       ...ich hab' noch einen Koffer in Berlin...
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>



More information about the Cplusplus-sig mailing list