change to python code