Various syntax fixes

While skim-reading the pyqgis developer cookbook, I noticed various oddities in the documentation caused by mistakes in the syntax. This series of commits fixes all the ones I've found.