replace the perl with python