
"Qinfeng(Javen) Shi " <shiqinfeng@gmail.com> writes:
Dear all,
I wraped a v_varray class into python by boost. I called it in python, most of its attributes work well. Only when I call a.push(1.0),it crashed due to not match type.
For the record, that's not a crash.
The problem is that my input argument in c++ is float*(for passing an array) while python has no pointer type.
That's one way to look at it.
How can I pass a variable in python to a.push() to make sure it work correctly?
Depends what you mean by "work correctly." You need to decide what semantics you want. If you want your float to be treated as an array of one element, you could use a "thin wrapper": void push(v_array<float*>& self, float x) { self.push(&x); } class_<v_array<float*> >("array_floatstar") .def("push", push) ... ; Of course, any modifications push makes to the float at the other end of the non-const pointer will be lost. Oh, and future Boost.Python questions should probably be directed to the C++-sig: http://www.boost.org/more/mailing_lists.htm#cplussig HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com