Boost logo

Boost :

From: Philippe Vaucher (philippe.vaucher_at_[hidden])
Date: 2007-07-25 03:55:22


FWIW, I think the boost::python doc really lack small example of simple
things, like:

1) How am I supposed to iterate over boost::python::object::operator[] ?
2) How am I supposed to iterate over boost::python::object::attr() ?

After googling a lot I found out that for 2) I could do :

boost::python::dict = boost::python::extract<boost::python::dict>(obj.attr
("__dict__"));
boost::python::object it = dict.iterkeys();
while(it)
{
   // use boost::python::extract<yourtype>(it()) here
   it.attr("next")();
}

But to find that out I really had to sweat. And I'm still looking for 1)...
and not close to find out because few people embed python into C++.
Philippe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk