Python Function Inside Function Javascript