swig/python problem: passing vector of objects.

Bo Peng bpeng at rice.edu
Sun Jun 20 02:59:01 EDT 2004


Dear List,

I have had success in using vector.i of SWIG to map between

   c++:     foo(vector<int>)
   python:  foo([1,2,3])

However, the map of vector of objects fails:

   c++:     foo(vector<obj> )
   python:  a = obj()
            foo([a])

Can anyone tell me
1. what exactly being passed to C++, a swig_pointer of a? Is there any 
copy constructure invloved during parameter passing?
2. It would be best for me to pass pointers of objects, i.e., I would like
      foo([a])   # python code
to do
       foo(vector<obj*>)

Is there any easy way to do it? (I do not know how to write SWIG maps.)

Many thanks in advance.

Bo



More information about the Python-list mailing list