title: How to access c++ object methods from inside vector with SWIG Python
body: <p>I have two C++ classes:  Foo and Bar.  The constructor for Foo looks like this:</p>
  
  <pre><code>Foo(std::vector&lt;Bar *&gt; * bars);
  </code></pre>
  
  <p>The constructor for Bar and one of its member functions are the following:</p>
  
  <pre><code>Bar(int data)
  int getData()
  </code></pre>
  
  <p>In my interface file I have:</p>
  
  <pre><code>%module mySwig
  %{
  #include "Foo.h"
  #include "Bar.h"
  #include &lt;vector&gt;
  %}
  
  %include "Foo.h"
  %include "Bar.h"
  %include "std_vector.i"
  namespace std {
      %template(VectorOfBars) vector&lt;Bar *&gt;;
  }
  </code></pre>
  
  <p>So then in python I do the following:</p>
  
  <pre><code>import mySwig
  myBar = mySwig.Bar(5)
  </code></pre>
  
  <p>And now I need to create a <code>std::vector&lt;Bar *&gt; *</code> object to pass into the Foo constructor, so I try the following:</p>
  
  <pre><code>vector = mySwig.VectorOfBars()
  vector.push_back(myBar)
  </code></pre>
  
  <p>To test if this was successful I try:</p>
  
  <pre><code>print vector
  print vector[0]
  print vector[0].getData()
  </code></pre>
  
  <p>If the result of the third print out is still "5" then it was successful, but instead I get what I'm assuming is a pointer value instead</p>
  
  <pre><code>&lt;mySwig.VectorOfBars; proxy of &lt;Swig Object of type 'std::vector&lt; Bar *,std::allocator&lt; Bar * &gt; &gt; *' at 0xb6a9c4d0&gt; &gt;
  &lt;mySwig.Bar; proxy of &lt;Swig Object of type 'std::vector&lt; Bar * &gt;::value_type' at 0xb6a9c3b0&gt; &gt;
  3069958048
  </code></pre>
  
  <p>What am I doing wrong?  How can I create the vector of Bar pointer objects that I need to pass in to make a Foo object?  Why am I getting a pointer value back instead of the actual value?</p>