Here also, sklearn.utils.gen_even_slices might be useful.