Python 3 version of PythonCard's model.py