Start rough translation from Perl to Python.