Miscellaneous cleanup and PEP8 compliance

This branch consists of three types of changes:

* doing type-checking with the PEP8 recommended techniques
* making the individual sections of the example code easier to distinguish
* compacting some function/method calls that span multiple lines but don't need to

The third one is largely a matter of taste/style and isn't that important. The second one I believe to be an improvement, though there is room for disagreement. The first one should absolutely be incorporated I think. In addition to being the right thing to do technically, it will improve the impression the code makes on experienced Python programmers.