PHP to Python