Boost documentation.

Alex Martelli aleaxit at yahoo.com
Wed Mar 28 14:35:12 EST 2001


"Jacek Generowicz" <jmg at ecs.soton.ac.uk> wrote in message
news:g0wv99x256.fsf at scumbag.ecs.soton.ac.uk...
> Are there any sources of documentation for the Boost Python Library
> besides the source examples, getting_started<1-5>.cpp ?

http://www.boost.org/libs/python/doc/index.html

(but the same docs should also have been received when you
downloaded and unpacked the boost package).


> How would I write a C++ function which receives a python list and
> converts it into a std::vector<int> for its own use ?

The only example of mine that I have at hand happens to use a not very
elegant approach, I'm not sure why (maybe other attempts didn't
work back when I wrote it, and I was in a hurry...):

void Deal::set_deck(boost::python::list data) {
    if(data.size() != PACK_CARDS) {
        PyErr_SetString(PyExc_ValueError, "deck must have exactly 52
cards");
        throw boost::python::error_already_set();
    }
    int i;
    PyObject* ppl = boost::python::to_python(data);
    for(i=0; i<PACK_CARDS; ++i)
        deck[i] = boost::python::from_python(PyList_GET_ITEM(ppl, i),
            boost::python::type<int>());
}


Alex






More information about the Python-list mailing list