[C++-sig] Re: implicitly_convertible
aashish
aashish at vrac.iastate.edu
Tue Jan 20 17:32:24 CET 2004
Hi,
I wanted to have a function like this where when I pass a list I will either
get return as set of integers or std::vector of double.
I tried to implement the function in this manner .....
C++--------------------------------
int make_vector(bp::list vlist)
{
//std::vector<double> vector_list;
int k = extract<int>(vlist.attr("__len__")());
/*for (int i=0;i<10;i++)
{
vector_list.push_back(extract<double>(lt.attr("__getitem__")(i)));
}
return vector_list;*/
int kk = extract<int>(vlist.attr("__getitem__")(0));
return kk;
}
Python-----------------------------
L = ['1','2','3']
a = make_vector(L)
print a
The problem is that I am getting the correct value for 'k' here but then it
does throws error saying that
Tracekack(most recent call last)
File "pytest2.py" , line 30, in ?
A = "make.vector"(L)
Typeerror: No registered converter was able to produce a C++ rvalue of type
int from this Python object of type str.
Now what does this error mean?? And How can sole this problem.
Thanks.
~regards,
Aashish
More information about the Cplusplus-sig
mailing list