change PHP to Python