Project: QGIS

Version: 2.0.0

Feature: New cleaner Python API

The Python API has been revamped to allow for a more cleaner, more pythonic, programming experience. The QGIS 2.0 API uses SIP V2 which removes the messy toString(), toInt() logic that was needed when working with values. Types are now converted into native Python types making for a much nicer API. Attributes access is now done on the feature itself using a simple key lookup, no more index lookup and attribute maps.

 >>> feature['mycolumn'] = 10
 >>> feature['mycolumn']
 10

The way features are read from a layer has also been improved allowing for multithreading in the future versions.

  for feature in layer.getFeatures():
         print feature['mycolumn']