Re: [boost] [python] set iteration

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): void 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: http://phenix-online.org/cctbx_sources/scitbx/include/scitbx/boost_python/co... Ralf ----- Original Message ---- From: Gennadiy Rozental <rogeeff@gmail.com> To: boost@lists.boost.org 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? Gennadiy _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (1)
-
Ralf W. Grosse-Kunstleve