Python class2

Reimplement this ahead of the python-restructure branch for easy merging.