diff -r e2e5181b10f8 Doc/library/itertools.rst --- a/Doc/library/itertools.rst Mon Dec 24 21:47:24 2012 +0200 +++ b/Doc/library/itertools.rst Tue Dec 25 00:39:40 2012 +0400 @@ -650,6 +650,10 @@ "Return first n items of the iterable as a list" return list(islice(iterable, n)) + def drop(n, iterable): + "Return items of the iterable except first n as a list" + return list(islice(iterable, n, None)) + def tabulate(function, start=0): "Return function(0), function(1), ..." return map(function, count(start)) @@ -730,6 +734,16 @@ t1, t2 = tee(iterable) return filterfalse(pred, t1), filter(pred, t2) + def splitat(t, iterable): + "Split iterable into two iterators after given number of iterations" + t1, t2 = tee(iterable) + return isice(t1, t), islice(t2, t, None) + + def splitby(pred, iterable): + "Split iterable into two iterators at first false predicate" + t1, t2 = tee(iterable) + return takewhile(pred, t1), dropwhile(pred, t2) + def powerset(iterable): "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)" s = list(iterable)