Update thomas.py

Porting to Python 3