<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'>The reason is to be more fast.<div>I think that restart an iterator is more fast than grab a new one from the same layer.</div><div>But I don't know if it's true!</div><div>Thanks<br><div><br><br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>Da: </b>"Nathan Woodrow" <madmanwoo@gmail.com><br><b>A: </b>"Stefano Masera" <stefano.masera@arpa.piemonte.it><br><b>Cc: </b>"qgis-user" <qgis-user@lists.osgeo.org><br><b>Inviato: </b>Lunedì, 21 ottobre 2013 15:56:35<br><b>Oggetto: </b>Re: [Qgis-user] How can I reset the starting point of a QgsFeatureIterator?<br><br><p dir="ltr">Just grab a new iterator.  Any reason you want to reuse the same iteratror.</p>
<div class="gmail_quote">On 21/10/2013 11:44 PM, "Stefano Masera" <<a href="mailto:stefano.masera@arpa.piemonte.it" target="_blank">stefano.masera@arpa.piemonte.it</a>> wrote:<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 style="">Hi list,</span><div style="">I use an iterator two times in a python code and I have to reset it to the starting point before to recall it.</div>
<div style=""><br></div><div style=""># first use of the iterator</div><div style="">iterator = layer.dataProvider().getFeatures()   </div><div style=""></div><div style="">for feature in iterator:</div><div style=""><span style="white-space:pre-wrap"> </span>#  operations</div>
<div style=""></div><div style=""># than, a second time I have to use the operator, in a following part of the code:</div><div style=""><div>for feature in iterator:</div><div><span style="white-space:pre-wrap">       </span>#  other operations</div>
</div><div style=""><br></div><div style="">But it doesn't start from the first feature!</div><div style=""></div><div style=""><br></div><div style="">I try with:</div><div style="">iterator.rewind()</div><div style=""><span style="font-size:12pt">between the two blocks, </span>but it doesn't work.</div>
<div style=""><br></div><div style="">Thanks.</div><div style=""></div><div style=""></div><div style=""></div><div style=""><br><div>Stefano Masera</div></div><br></div></div><br>_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br></blockquote></div>
</div><br></div></div></div></body></html>