4

I have been using the following Python code on QGIS 3 (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?

Taras
35.7k5 gold badges77 silver badges151 bronze badges
asked Jan 23, 2018 at 23:49

1 Answer 1

8

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

I saw a question (not available) from @Andreas Neumann on the qgis-dev mailing list regarding the same question.

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

Taras
35.7k5 gold badges77 silver badges151 bronze badges
answered Jan 24, 2018 at 7:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.