My second PyQGIS code snippet - looping the layer features