[C++-sig] boost python references
roman.yakovenko at gmail.com
Sun Apr 16 12:53:36 CEST 2006
On 4/15/06, david stummer <stummer at gmail.com> wrote:
> hi guys,
> i am trying to use references with boost python.
> in python you can do:
> class person:
> print a.name
> print b.name
> because b is a reference, it will always change as a changes. hence b.name
> is also john.
> i want this functionality between boost and python.
> I have the C++ class:
> .def_readwrite("seat", &Window::seat)
> where seat is an object of class Seat. Seat contains an integer attribute
> named position. It's default value is 45.
> How can i used references?
There is one important difference between Python code and C++.
In Python you create value that belongs to class, while in C++ you
create value that
belongs to class instance. I think you should use add_static_property function.
Also, I think you will need to use boost::python::make_function in order to
construct getter/setter with desired call policies.
C++ Python language binding
More information about the Cplusplus-sig