Got the supplied code working with python 3 and inside a class