[C++-sig] __getitem__ and __setitem__ for a Matrix class
sashan
sashang at ihug.co.nz
Tue Dec 10 01:46:45 CET 2002
Hi
I want to expose a matrix class's operator[]. To expose it as an rvalue
I did the following
boost::python::list GetList(Matrix3& self, int i)
{
if (!(i < 3 && i > -1))
{
PyErr_SetObject(PyExc_IndexError, PyInt_FromLong(i));
boost::python::throw_error_already_set();
}
boost::python::list list;
list.append(self[i][0]);
list.append(self[i][1]);
list.append(self[i][2]);
return list;
}
.
.
.
classMatrix3.def("__getitem__", &GetList);
However I don't know/can't figure out how to expose it as an lvalue?
Thanks
--
sashan
-------------------------------
P: Egad! You astound me, Brain!
B: That's a simple task, Pinky.
More information about the Cplusplus-sig
mailing list