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') >>>iface.setActiveLayer(vl)
>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'.
>>>fields = vl.pendingFields() >>>fields.toList()
[<qgis._core.QgsField object at 0x11f24a770>, <qgis._core.QgsField object at 0x11f24aa68>, <qgis._core.QgsField object at 0x11f24ab00>, <qgis._core.QgsField object at 0x11f24ab98>, <qgis._core.QgsField object at 0x11f24ac30>, <qgis._core.QgsField object at 0x11f24acc8>
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?