Javascript to Python