1

I have been using the following python code on QGIS3 (2.99) to look up fields, for several months

id = feature.attributes()[layer.pendingFields().lookupField('ID')]

And it gives me an error today:

AttributeError: 'QgsVectorLayer' object has no attribute 'pendingFields'

Is this another breaking change in the QGIS development version? And what's the correct way to write it now?

4

The answer seems to be yes, another change in QGIS 2.99.

I saw a question from Andreas Neumann on the qgis-dev mailing list regarding the same question.

Etienne Trimaille and Alessandro Pasotti reveals that pendingFields() is removed and suggest that you instead should use fields().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.