Assuming you have a function that takes std::vector<Foo>
void bar (std::vector<Foo> arg)
The easiest way to handle this is to open python vector .
BOOST_PYTHON_MODULE(awesome_module) { class_<Foo>("Foo") //methods and attrs here ; class_<std::vector<Foo> >("VectorOfFoo") .def(vector_indexing_suite<std::vector<foo> >() ) ; .def("bar", &bar) }
So now in python we can insert Foo into vector and pass the vector to bar
from awesome_module import * foo_vector = VectorOfFoo() foo_vector.extend(Foo(arg) for arg in arglist) bar(foo_vector)
Matthew scouten
source share