0

I have some C++ code wrapped using SWIG, and want to map a simple array of objects to a Python list. A much simplified example:

class Point {
  int x;
  int y;
};

class Polygon {
  Point *ptlist();
  int numPoints();
...
};

I want to be able to access ptlist() in Python as a sequence of Points, but can't find any obvious way of doing this using e.g. %extend or typemaps. Any help would be appreciated.

3
  • I wrote an answer that outlines a few approaches to this problem a while back: stackoverflow.com/a/8828454/168175 does that solve it for you? Commented Apr 8, 2016 at 8:02
  • Thanks, the typemap example helped solve the problem. Commented Apr 9, 2016 at 14:44
  • I've marked it as a duplicate then on that basis, but I'm more than happy to reopen this if you don't agree. Commented Apr 9, 2016 at 15:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.