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
1 Answer 1
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
:
It finds iface
because that is imported for you.
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.
-
Thanks that helped allotChace Carpenter– Chace Carpenter2022年08月11日 23:44:44 +00:00Commented 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 ✓.Kadir Şahbaz– Kadir Şahbaz2022年08月12日 07:56:24 +00:00Commented Aug 12, 2022 at 7:56