array of strings in boost python

Hi,
newbie in python and boost::python
I have a method in c++ that returns a vector of strings, how can i
expose this method in python, and how should i use it in python
class A
{
public:
std::vectorstd::string getName();
};
BOOST_PYTHON_MODULE(pysession)
{
class_<A>("A")
.def("GetName" ,&A::getName)
}
now in python how could i call the function getName() ?
here is my error in python
TypeError: No to_python (by-value) converter found for C++ type: class
std::vect
or

Hi,
newbie in python and boost::python
Please post Boost.Python questions to the C++-sig: http://www.boost.org/more/mailing_lists.htm#cplussig
I have a method in c++ that returns a vector of strings, how can i expose this method in python, and how should i use it in python
Sorry to turn the question around on you, but how do you /want/ to be able to use it in Python? That will determine how you should expose it. You might look into http://boost.org/libs/python/doc/v2/indexing.html#vector_indexing_suite_clas... to see if it meets your needs. -- Dave Abrahams Boost Consulting www.boost-consulting.com

# dave@boost-consulting.com / 2006-09-11 06:55:11 -0400:
writes: newbie in python and boost::python
Please post Boost.Python questions to the C++-sig: http://www.boost.org/more/mailing_lists.htm#cplussig
Wouldn't putting this in http://www.boost.org/libs/python/doc/index.html reduce the B.Py traffic on this list? The URL you refer to (http://www.python.org/community/sigs/c++-sig/) gives a 404, a working c++-sig page can be found at http://www.python.org/community/sigs/current/c++-sig/ Sadly, there's no mention of a mailing list on that page, and the only three links point back to boost.org. You need to read the Mailing Lists page (main menu on the left) carefully to catch the "complete listing of python.org's mailing lists" at the very top. Minor bitching aside, thanks for B.Py! -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991

Roman Neuhauser
# dave@boost-consulting.com / 2006-09-11 06:55:11 -0400:
writes: newbie in python and boost::python
Please post Boost.Python questions to the C++-sig: http://www.boost.org/more/mailing_lists.htm#cplussig
Wouldn't putting this in http://www.boost.org/libs/python/doc/index.html reduce the B.Py traffic on this list?
I don't know, but it's not a bad idea.
The URL you refer to (http://www.python.org/community/sigs/c++-sig/) gives a 404,
Ouch.
a working c++-sig page can be found at http://www.python.org/community/sigs/current/c++-sig/
Sadly, there's no mention of a mailing list on that page, and the only three links point back to boost.org. You need to read the Mailing Lists page (main menu on the left) carefully to catch the "complete listing of python.org's mailing lists" at the very top.
Could you submit patches to repair these problems? It would be much appreciated! -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
ctremblaï¼ pcigeomatics.com
-
David Abrahams
-
Roman Neuhauser