replace php stuff with python