March 7, 2003
6:52 p.m.
harold fellermann <harold@imb-jena.de> writes:
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. For a dictionary you can call items() and then do the same. However, it would be interesting to make a standard input_iterator that could iterate over the items, e.g.: for ( input_iterator i = begin(some_list_or_dict); i != end(some_list_or_dict); ++i) { whatever(*i); } Nice project for someone who wants to make a contribution. -- Dave Abrahams Boost Consulting www.boost-consulting.com