Boost logo

Boost :

From: Ralf W. Grosse-Kunstleve (rwgk_at_[hidden])
Date: 2008-03-21 19:08:23

In C++?
I don't know the most elegant solution, but one that should work
easily is to convert the set to a boost::python::list, maybe (untested):

  foo(boost::python::object s)
    boost::python::list l(s);
    long n = boost::python::len(l);
    for(long i=0;i<n;i++) {
      boost::python::extract<int> proxy(l[i]);
      int v = proxy();

Probably, a more efficient solution is to use PyObject_GetIter() and
PyIter_Next(), but to make this safe you have to mess with
boost::python::handle<> and PyErr_Clear(). Look here for a related example:


----- Original Message ----
From: Gennadiy Rozental <rogeeff_at_[hidden]>
To: boost_at_[hidden]
Sent: Friday, March 21, 2008 11:45:18 AM
Subject: [boost] [python] set iteration

How do I iterate over object that correspond to python set?


Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at