[C++-sig] Re: module unloading callback?

aashish aashish at vrac.iastate.edu
Tue Jan 20 23:02:22 CET 2004


Hi, 

I am sorry about asking so many question but I have to as I am new to the
world of C++/Python and couldn't find my answers on Google. 


I need to do something like this so that on the python side I will get the
object of type std::vector (I now that I might need to use
to_python_converter but I couldn't understand the documentation)


std::vector <int>  make_vector(bp::list vlist)
{
	std::vector<int> vector_list;

	int list_length = extract<int>(vlist.attr("__len__")());	
	
	for ( int i = 0; i < list_length; i++ )
	{
	    			
	
vector_list.push_back(extract<int>(vlist.attr("__getitem__")(list_length)));
	}

	
	return vector_list;
	
	
}

And it compiled fine but whenI did something like this on python side I got
the error 

L = [1,2,3]
a = make_vector(L)
print a

saying that "No to_python (by value) converter found for C++ class
std""vector<int, class std::allocator<int> >

Can someone tell how to solve this problem...I know what the problem might
be but  I don't know the solution. 

Thanks, 
Aashish 







More information about the Cplusplus-sig mailing list