[QGIS-Developer] FeatureIterator Python question

Matthias Kuhn matthias at opengis.ch
Fri Sep 15 06:47:43 PDT 2017


I quickly googled for the reason for this

PEP 3114 (https://www.python.org/dev/peps/pep-3114/)

So next() was renamed to __next__() for consistency, because it's a
builtin method.

iterator.__next__() or next(iterator) should yield the same item.

Matthias

On 09/15/2017 03:44 PM, matteo wrote:
> Hi Andreas,
> 
> if I'm not wrong the next method is not been removed, it is a python 3 *fix*
> 
> https://stackoverflow.com/questions/1073396/is-generator-next-visible-in-python-3-0
> 
> so instead of:
> 
> it = layer.getFeatures()
> it.next()
> 
> just type
> 
> it = layer.getFeatures()
> next(it)
> 
> Matteo
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> 


More information about the QGIS-Developer mailing list