First translation to python