Add foldmethod for python