[C++-sig] Passing a C++ instance to a Python script
Francis Moreau
fmoreau at paraxip.com
Wed Feb 7 20:49:53 CET 2007
Thanks for the quick response. As you know the function exec_file is only
available in version 1.34, what is the best way to get this version? If it
is through cvs do I have to get the head or there is a stable tag somewhere?
Thanks,
Francis
"Stefan Seefeld" <seefeld at sympatico.ca> wrote in message
news:<45C8D2DC.8080309 at sympatico.ca>...
> Francis Moreau wrote:
> > Hello,
> >
> > I need to pass a C++ instance to a Python function, then the Python
function
> > can call back the C++ instance object. I found this following sample
that do
> > it well when the script is embedded into the C++ code within the
> > PyRun_String function. I need to have something similar but with the
> > PyRun_String content in a .py file. As a matter of fact, when I am
trying to
> > move the PyRun_String content into a .py file the line "object
> > foo(main_module.attr("foo"));" fails since the foo function is unknown
from
> > the main dictionary.
>
> Have a look at the test code in boost/libs/python/test/exec.cpp
>
(http://boost.cvs.sourceforge.net/boost/boost/libs/python/test/exec.cpp?revi
sion=1.5.2.1&view=markup&pathrev=RC_1_34_0)
>
> I think that contains all you need.
>
> HTH,
> Stefan
>
> --
>
> ...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list