Python folding