from qgis.core import *

QgsApplication.setPrefixPath('/usr/local', True)
QgsApplication.initQgis()
# load a layer
vlayer = QgsVectorLayer('polygons.shp', 'layer_name', 'ogr')
if vlayer.isValid():
  print 'layer is valid'
  # get the data provider
  vprovider = vlayer.dataProvider()
  # get index of field 'name' 
  name_index = vprovider.fieldNameIndex('name')
  # there are NULL values in the field 'name' on sample dataset
  unique = vprovider.uniqueValues(name_index)
  print unique
