|
From: Josh C. <jc...@nc...> - 2006-08-29 03:08:18
|
On Sun, 27 Aug 2006, Mike Coleman wrote: > Josh, thanks for your reply. Yes, I meant that I wanted v[0] to give > me a handle (or whatever) on the vector of double in question (which > can more-or-less be treated like a list). I picked through the source > a little in the latest swig, and it looks like this feature isn't > really there, or at least I don't see it. There is a #define (the > name of which I've forgotten) that will cause the access to return a > list (or vector of double), but it's disposable and no change to it > will stick. When I try wrapping a vector of vectors of doubles with my own stl stuff, which is similar to the older stl support that came with SWIG, append() seems to work the way you want it to (see http://www.ncbi.nlm.nih.gov/cvsweb/index.cgi/internal/c%2b%2b/src/wrappers/python/). The key thing is that __getitem__ is declared to return a non-const reference to the contained class. I'm guessing that with the stl stuff you're using it is declared to return the contained vector by value or const ref, and "out" typemaps for vector<double> return a Python tuple or list, which is sometimes convenient. Josh |