I'm trying to modify the values of some selected features. I have written this small script, but nothing happens when I run it. Is there something that I've missed? Here is my code.
lyr = qgis.utils.iface.activeLayer()
features = lyr.selectedFeatures()
lyr.startEditing()
lyr.updateFields()
for f in features:
fid= f.id()
lyr.changeAttributeValue(fid,12,"0")
lyr.updateFeature(f)
print "elemento alterado"
lyr.commitChanges()