I have a method in c++ that gets called from python and needs to return a python list object.
I have already created the method, and its attached to an exposed class
If you only want to create python list manually (and have the function return py::list rather than vector), do it like this:
/* using namespace std; namespace py=boost::python;
#define FOREACH BOOST_FOREACH
*/
vector ss;
py::list ret;
FOREACH(const string& s, ss) ret.append(s);
return s;
For automatic conversions, define the converter for vector from python list to c++ and from c++ to python list -- I just wrote about that at Instantiating shared_ptr's in boost::python (the second part of the reply); that way, you get realy python lists.
Another possibility for automatic conversion (which I have no experience with) is to use indexing_suite, which will wrap vector as a special class in python, as a colleague mentioned here already.