1

Why are neither of the commands below returning details on the active layer method?

It works when I use the class iface.

help(activeLayer)
help(activeLayer()) 

This is the error I get

Traceback (most recent call last): File "C:\PROGRA~1\QGIS32~1.1\apps\Python39\lib\code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in NameError: name 'activeLayer' is not defined

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Aug 11, 2022 at 13:32

1 Answer 1

2

This is because Python doesn't have activeLayer imported into the current namespace, so it can't find it. Its not just the help that doesn't work, nothing will find activeLayer:

enter image description here

It finds iface because that is imported for you.

enter image description here

You can do dir() to see what is imported. You can do dir(iface) to see what the iface object has for you.

So to get the help on the activeLayer object, you can do help(iface.activeLayer) since activeLayer is a property of iface and iface is imported.

enter image description here

answered Aug 11, 2022 at 13:46
2
  • Thanks that helped allot Commented Aug 11, 2022 at 23:44
  • 1
    @ChaceCarpenter If you like the answer and it was helpful, please consider upvoting by clicking on the arrows next to the score and/or marking it as the accepted answer by clicking on the checkmark ✓. Commented Aug 12, 2022 at 7:56

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.