[Qgis-developer] How can I reset the starting point of a QgsFeatureIterator?

Stefano Masera stefano.masera at arpa.piemonte.it
Wed Oct 23 07:19:53 PDT 2013


Hi list, 
I use an iterator two times in a python code and I wantto reset it to the starting point before to reuse it. 
In this way I hope to be more quick. 


# first use of the iterator 
iterator = layer.dataProvider().getFeatures() 

for feature in iterator: 
# operations 

# than, a second time I have to use the operator, in a following part of the code: 

for feature in iterator: 
# other operations 


But it doesn't start from the first feature! 



I try with: 
iterator.rewind() 
between the two blocks, but it doesn't work. 


Thanks. 





Stefano Masera 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131023/8159c1fc/attachment.html>


More information about the Qgis-developer mailing list