How can I stop QGIS from printing True
twice in python console for each updated record? This is slowing down the calculations.
Example:
layer = iface.activeLayer()
with edit(layer):
for feature in layer.getFeatures():
if feature['Randint'] % 2 == 0:
new_value = 'Even'
else:
new_value = 'Odd'
feature.setAttribute(feature.fieldNameIndex('Parity'), new_value)
layer.updateFeature(feature)
_ = layer.updateFeature(feature)
and the same for setAttribute_ = feature.setAttribute(feature.fieldNameIndex('Parity'), new_value)