I want to know how to get the QGIS Console to print out actual values pertaining to a Layer's attribute table (e.g. field names, feature values, etc.).
So far using the "print" command all I'm able to get are object references.
The next 2 examples involve a shapefile of mine called 'Province', and are predicated by the following code:
>>>vl = QgsMapLayerRegistry.instance().mapLayersByName('Province')[0]>>>iface.setActiveLayer(vl)Example 1:
>>>print vlOutput:
>qgis._core.QgsVectorLayer object at 0x11f24a348<A vector layer object reference is returned, but I want the actual name of the layer, which of course is 'Province'.
Example 2:
>>>fields = vl.pendingFields()>>>fields.toList()Output:
[, , , , , Granted, I used "toList()" rather than "print", but the result is the same: rather than the actual names of the fields I get an array of object references.
How do you tell Console to give you the actual values that you happen to be storing in a given variable, rather than the object refs?
Much obliged.
أكثر...
So far using the "print" command all I'm able to get are object references.
The next 2 examples involve a shapefile of mine called 'Province', and are predicated by the following code:
>>>vl = QgsMapLayerRegistry.instance().mapLayersByName('Province')[0]>>>iface.setActiveLayer(vl)Example 1:
>>>print vlOutput:
>qgis._core.QgsVectorLayer object at 0x11f24a348<A vector layer object reference is returned, but I want the actual name of the layer, which of course is 'Province'.
Example 2:
>>>fields = vl.pendingFields()>>>fields.toList()Output:
[, , , , , Granted, I used "toList()" rather than "print", but the result is the same: rather than the actual names of the fields I get an array of object references.
How do you tell Console to give you the actual values that you happen to be storing in a given variable, rather than the object refs?
Much obliged.
أكثر...