From 17c4ce61826cde38ffea1ac3f9b21ce5e2bd42e6 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sat, 6 Aug 2016 12:55:59 +0200 Subject: [PATCH] getitem MeshPoint --- libsrc/meshing/python_mesh.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index b6a9675e..32b8834d 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -105,14 +105,11 @@ DLL_HEADER void ExportNetgenMeshing() .def(bp::init>()) .def("__str__", &ToString) .def("__repr__", &ToString) - .add_property("p", FunctionPointer([](const MeshPoint & self) - { - bp::list l; - l.append ( self[0] ); - l.append ( self[1] ); - l.append ( self[2] ); - return bp::tuple(l); - })) + .def("__getitem__", FunctionPointer([](const MeshPoint & self, int index) { + if(index<0 || index>2) + bp::exec("raise IndexError()\n"); + return self[index]; + })) ; bp::class_("Element3D")