# Source

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42``` ```============ python-split ============ Functions to split and partition sequences. Installation ------------ :: pip install split Usage ----- To partition a sequence into chunks of equal size, use ``chop``:: >>> from split import chop >>> list(chop(3, range(10))) [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]] If ``truncate=True`` keyword argument is given, sequence length is truncated to a multiple of chunk size, and all chunks have the same size:: >>> list(chop(3, range(10), truncate=True)) [[0, 1, 2], [3, 4, 5], [6, 7, 8]] To split a sequence into two by a given predicate, use ``partition``:: >>> from split import partition >>> def odd(x): return x%2 >>> map(list, partition(odd, range(5))) [[1, 3], [0, 2, 4]] To break a sequence into chunks on some separator elements, use ``split``:: >>> list(split(0, [1,2,3,0,4,5,0,0,6])) [[1, 2, 3], [4, 5], [], [6]] All functions return iterators. ```