folding for python