March 11, 2003
2:46 p.m.
harold fellermann wrote:
hello,
Is there any possibility to iterate trough a boost::python::list (or dictionary) from within C++ ? I could not find anything in the documentation.
Well, for a list you can call x.attr("__len__")() to get its length and index it.
how can I convert the return type list.attr("__len__") from boost::python::api::proxy<boost::python::api::const_attribute_policies> to size_t?
As Dave mentioned, you need to use x.attr("__len__")(). Notice the *additional* pair of braces.
will it then be possible to reach the elements of the list via 'list[index]'
Yes. Dirk Gerrits