[C++-sig] Problem with boost::python::iterator
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Mon Dec 8 16:07:58 CET 2003
I use boost::python::iterator to export a python iterator from STL
containers. More precisely, I use :
.def("__iter__", boost::python::iterator<Container>())
where Container is a STL container ( vector<foo> for example ). Let's
say that foo is a class that contains an integer 'a'. My problem is with
this following test:
>>> l = vector_foo()
>>> l.append(foo(3))
>>> l.append(foo(2))
>>> l.append(foo(10))
>>> print l
vector_foo{ foo(3), foo(2), foo(10) }
>>> for i in l:
... i.a = i.a + 3
...
>>> print l
vector_foo{ foo(3), foo(2), foo(10) }
I don't understand !!! It used to work, but it does not anymore ! If you
replace the variable (defined as readwrite) by a function call modifying
the object it does not modify the vector !
This is a very big problem for me !!! What can I do ?
Thanks,
--
Pierre Barbier de Reuille
INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France
tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68
More information about the Cplusplus-sig
mailing list