Lines Matching refs:itertools
12 :mod:`itertools` and :mod:`functools`.
735 The itertools module
738 The :mod:`itertools` module contains a number of commonly-used iterators as well
752 :func:`itertools.count(start, step) <itertools.count>` returns an infinite
756 itertools.count() =>
758 itertools.count(10) =>
760 itertools.count(10, 5) =>
763 :func:`itertools.cycle(iter) <itertools.cycle>` saves a copy of the contents of
767 itertools.cycle([1, 2, 3, 4, 5]) =>
770 :func:`itertools.repeat(elem, [n]) <itertools.repeat>` returns the provided
773 itertools.repeat('abc') =>
775 itertools.repeat('abc', 5) =>
778 :func:`itertools.chain(iterA, iterB, ...) <itertools.chain>` takes an arbitrary
783 itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>
786 :func:`itertools.islice(iter, [start], stop, [step]) <itertools.islice>` returns
793 itertools.islice(range(10), 8) =>
795 itertools.islice(range(10), 2, 8) =>
797 itertools.islice(range(10), 2, 8, 2) =>
800 :func:`itertools.tee(iter, [n]) <itertools.tee>` replicates an iterator; it
808 itertools.tee( itertools.count() ) =>
827 :func:`itertools.starmap(func, iter) <itertools.starmap>` assumes that the
831 itertools.starmap(os.path.join,
844 :func:`itertools.filterfalse(predicate, iter) <itertools.filterfalse>` is the
848 itertools.filterfalse(is_even, itertools.count()) =>
851 :func:`itertools.takewhile(predicate, iter) <itertools.takewhile>` returns
858 itertools.takewhile(less_than_10, itertools.count()) =>
861 itertools.takewhile(is_even, itertools.count()) =>
864 :func:`itertools.dropwhile(predicate, iter) <itertools.dropwhile>` discards
868 itertools.dropwhile(less_than_10, itertools.count()) =>
871 itertools.dropwhile(is_even, itertools.count()) =>
874 :func:`itertools.compress(data, selectors) <itertools.compress>` takes two
878 itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>
885 The :func:`itertools.combinations(iterable, r) <itertools.combinations>`
889 itertools.combinations([1, 2, 3, 4, 5], 2) =>
895 itertools.combinations([1, 2, 3, 4, 5], 3) =>
903 :func:`itertools.permutations(iterable, r=None) <itertools.permutations>`,
907 itertools.permutations([1, 2, 3, 4, 5], 2) =>
914 itertools.permutations([1, 2, 3, 4, 5]) =>
925 itertools.permutations('aba', 3) =>
932 The :func:`itertools.combinations_with_replacement(iterable, r) <itertools.combinations_with_replac…
938 itertools.combinations_with_replacement([1, 2, 3, 4, 5], 2) =>
949 The last function I'll discuss, :func:`itertools.groupby(iter, key_func=None)
950 <itertools.groupby>`, is the most complicated. ``key_func(elem)`` is a function
954 :func:`~itertools.groupby` collects all the consecutive elements from the
969 itertools.groupby(city_list, get_state) =>
982 :func:`~itertools.groupby` assumes that the underlying iterable's contents will
1067 A related function is :func:`itertools.accumulate(iterable, func=operator.add)
1068 <itertools.accumulate>`. It performs the same calculation, but instead of
1072 itertools.accumulate([1, 2, 3, 4, 5]) =>
1075 itertools.accumulate([1, 2, 3, 4, 5], operator.mul) =>
1240 Documentation for the :mod:`itertools` module.
1256 import itertools
1258 slice = itertools.islice(it, 10)