<div dir="ltr">When the iterator has given back all the features it gets closed. <div>Rewind works only while the iterator si open, so it's supposed to work while you're stepping through the iteration.</div><div>I fear you have to obtain a new iterator to repreat the iteration.</div>
<div><br></div><div>giovanni</div><div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/23 Stefano Masera <span dir="ltr"><<a href="mailto:stefano.masera@arpa.piemonte.it" target="_blank">stefano.masera@arpa.piemonte.it</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif">No, it does False!<div><br></div><div>
But if I put <br>iterator.rewind()</div><div>before the first use of the iterator it does True.</div><div><br></div><div><br></div><div><br><hr><div style="font-size:12pt;font-style:normal;font-family:Helvetica,Arial,sans-serif;text-decoration:none;font-weight:normal">
<b>Da: </b>"G. Allegri" <<a href="mailto:giohappy@gmail.com" target="_blank">giohappy@gmail.com</a>><br><b>A: </b>"Stefano Masera" <<a href="mailto:stefano.masera@arpa.piemonte.it" target="_blank">stefano.masera@arpa.piemonte.it</a>><br>
<b>Cc: </b>"qgis-developer" <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank">qgis-developer@lists.osgeo.org</a>><br><b>Inviato: </b>Mercoledė, 23 ottobre 2013 16:36:12<br><b>Oggetto: </b>Re: [Qgis-developer] How can I reset the starting point of a QgsFeatureIterator?<br>
<br><div dir="ltr">Does <span style="font-family:'times new roman','new york',times,serif;font-size:16px">iterator.rewind() return True?</span></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/10/23 Stefano Masera <span dir="ltr"><<a href="mailto:stefano.masera@arpa.piemonte.it" target="_blank">stefano.masera@arpa.piemonte.it</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><span>Hi list,</span><div>
I use an iterator two times in a python code and I wantto reset it to the starting point before to reuse it.</div><div>In this way I hope to be more quick.</div><div><br></div><div># first use of the iterator</div>
<div>iterator = layer.dataProvider().getFeatures() </div><div></div><div>for feature in iterator:</div><div><span style="white-space:pre-wrap"> </span># operations</div><div></div><div>
# than, a second time I have to use the operator, in a following part of the code:</div><div><div>for feature in iterator:</div><div><span style="white-space:pre-wrap"> </span># other operations</div></div><div>
<br></div><div>But it doesn't start from the first feature!</div><div></div><div><br></div><div>I try with:</div><div>iterator.rewind()</div><div><span style="font-size:12pt">between the two blocks, </span>but it doesn't work.</div>
<div><br></div><div>Thanks.</div><span><font color="#888888"><div></div><div></div><div></div><div><br><div>Stefano Masera</div></div><br></font></span></div></div><br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br>
<br clear="all"><div><br></div>-- <br>Giovanni Allegri<br>
<a href="http://about.me/giovanniallegri" target="_blank">http://about.me/giovanniallegri</a><br>blog: <a href="http://blog.spaziogis.it" target="_blank">http://blog.spaziogis.it</a><br>GEO+ geomatica in Italia <a href="http://bit.ly/GEOplus" target="_blank">http://bit.ly/GEOplus</a>
</font></span></div>
</div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Giovanni Allegri<br><a href="http://about.me/giovanniallegri" target="_blank">http://about.me/giovanniallegri</a><br>blog: <a href="http://blog.spaziogis.it" target="_blank">http://blog.spaziogis.it</a><br>
GEO+ geomatica in Italia <a href="http://bit.ly/GEOplus" target="_blank">http://bit.ly/GEOplus</a>
</div>