Update to comply with PEP8, and convert some comments to doccomments.

Also remove a duplicated, identical, copy of the domain() method, and convert some examples in the doccomments to doctests.