[C++-sig] Calling member function of object created in C++ via embedded Python

Roman Yakovenko roman.yakovenko at gmail.com
Fri Apr 13 22:24:59 CEST 2007


On 4/13/07, Ron Brown, Jr. <rbrown at gamry.com> wrote:
> Roman,
> However, regarding your response of:
>
> Roman Yakovenko wrote:
>  > namespace bpl = boost::python;
>  > bpl::object py_wo( World() );
>  > bpl::call_method<void >(py_wo, "set", "Hello World");
>  >
>  > I think this should work
>
> Now unless I'm just misunderstanding, what you're doing there is not
> exactly what I'm trying to do.  Wouldn't that code just create ANOTHER
> object of class World on the Python side?  Again, I'm embedding Python
> in a C++ app, and what I'm trying to do is just pass an
> already-instantiated object from the C++ through to Python, and then in
> Python, call one of that particular object's member functions.  I want
> to use the SAME object in both C++ and Python.

Now I understand. I think you are looking for next functionality:
http://boost.org/libs/python/doc/v2/ptr.html

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list