It should work like this (untested):

  boost::python::ssize_t n = boost::python::len(your_list);
  for(boost::python::ssize_t i=0;i<n;i++) {
    boost::python::object elem = your_list[i];
  }



----- Original Message ----
From: Hans Roessler <hansroess...@yahoo.de>
To: Development of Python/C++ integration <cplusplus-sig@python.org>
Sent: Thursday, May 21, 2009 2:08:03 PM
Subject: [C++-sig] iterate a boost::python::list


How can I iterate in C++ over a boost::python::list?

According to http://www.boost.org/doc/libs/1_39_0/libs/python/doc/v2/list.html 
it has no begin() and end() functions.
Neither a size() function that would allow to call pop(size()-1). Neither an 
isEmpty() function that would allow to call pop(0) until the list is empty.

I'm sure I'm missing something trivial. Can somebody help me?

Thanks
Hans

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to