ChatGPT - PHP to Python Conversion