# HG changeset patch # User Sergey Astanin # Date 1349896958 -7200 # Node ID d8367a089052668e57c4393662bb3b2c31f8d6a4 # Parent 597e189e32fa66b56620d6fdae2dead5f4fa4677 README in rst markup diff --git a/README b/README --- a/README +++ b/README @@ -1,35 +1,40 @@ -python-split -- functions to split and partition sequences -========================================================== +============ +python-split +============ + +Functions to split and partition sequences. Installation ------------ +:: + pip install split Usage ----- -To partition a sequence into chunks of equal size, use `chop`: +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 +If ``truncate=True`` keyword argument is given, sequence length is truncated to a multiple of chunk size, and all chunks have the same -size. +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`: +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`: +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]]