maxim-yurchuk 9731d8a4bb publishFullContrib: true for ydb 1 month ago
..
.dist-info e0e3e1717e add ydb deps 1 year ago
more_itertools 9731d8a4bb publishFullContrib: true for ydb 1 month ago
patches 9731d8a4bb publishFullContrib: true for ydb 1 month ago
tests e0e3e1717e add ydb deps 1 year ago
LICENSE e0e3e1717e add ydb deps 1 year ago
README.rst e0e3e1717e add ydb deps 1 year ago
ya.make e0e3e1717e add ydb deps 1 year ago

README.rst

==============
More Itertools
==============

.. image:: https://coveralls.io/repos/github/erikrose/more-itertools/badge.svg?branch=master
:target: https://coveralls.io/github/erikrose/more-itertools?branch=master

Python's ``itertools`` library is a gem - you can compose elegant solutions
for a variety of problems with the functions it provides. In ``more-itertools``
we collect additional building blocks, recipes, and routines for working with
Python iterables.

----

+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grouping | `chunked `_, |
| | `sliced `_, |
| | `distribute `_, |
| | `divide `_, |
| | `split_at `_, |
| | `split_before `_, |
| | `split_after `_, |
| | `bucket `_, |
| | `grouper `_, |
| | `partition `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Lookahead and lookback | `spy `_, |
| | `peekable `_, |
| | `seekable `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Windowing | `windowed `_, |
| | `stagger `_, |
| | `pairwise `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Augmenting | `count_cycle `_, |
| | `intersperse `_, |
| | `padded `_, |
| | `adjacent `_, |
| | `groupby_transform `_, |
| | `padnone `_, |
| | `ncycles `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Combining | `collapse `_, |
| | `sort_together `_, |
| | `interleave `_, |
| | `interleave_longest `_, |
| | `collate `_, |
| | `zip_offset `_, |
| | `dotproduct `_, |
| | `flatten `_, |
| | `roundrobin `_, |
| | `prepend `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Summarizing | `ilen `_, |
| | `first `_, |
| | `last `_, |
| | `one `_, |
| | `unique_to_each `_, |
| | `locate `_, |
| | `rlocate `_, |
| | `consecutive_groups `_, |
| | `exactly_n `_, |
| | `run_length `_, |
| | `map_reduce `_, |
| | `all_equal `_, |
| | `first_true `_, |
| | `nth `_, |
| | `quantify `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Selecting | `islice_extended `_, |
| | `strip `_, |
| | `lstrip `_, |
| | `rstrip `_, |
| | `take `_, |
| | `tail `_, |
| | `unique_everseen `_, |
| | `unique_justseen `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Combinatorics | `distinct_permutations `_, |
| | `circular_shifts `_, |
| | `powerset `_, |
| | `random_product `_, |
| | `random_permutation `_, |
| | `random_combination `_, |
| | `random_combination_with_replacement `_, |
| | `nth_combination `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Wrapping | `always_iterable `_, |
| | `consumer `_, |
| | `with_iter `_, |
| | `iter_except `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Others | `replace `_, |
| | `numeric_range `_, |
| | `always_reversible `_, |
| | `side_effect `_, |
| | `iterate `_, |
| | `difference `_, |
| | `make_decorator `_, |
| | `SequenceView `_, |
| | `consume `_, |
| | `accumulate `_, |
| | `tabulate `_, |
| | `repeatfunc `_ |
+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+


Getting started
===============

To get started, install the library with `pip `_:

.. code-block:: shell

pip install more-itertools

The recipes from the `itertools docs `_
are included in the top-level package:

.. code-block:: python

>>> from more_itertools import flatten
>>> iterable = [(0, 1), (2, 3)]
>>> list(flatten(iterable))
[0, 1, 2, 3]

Several new recipes are available as well:

.. code-block:: python

>>> from more_itertools import chunked
>>> iterable = [0, 1, 2, 3, 4, 5, 6, 7, 8]
>>> list(chunked(iterable, 3))
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]

>>> from more_itertools import spy
>>> iterable = (x * x for x in range(1, 6))
>>> head, iterable = spy(iterable, n=3)
>>> list(head)
[1, 4, 9]
>>> list(iterable)
[1, 4, 9, 16, 25]



For the full listing of functions, see the `API documentation `_.

Development
===========

``more-itertools`` is maintained by `@erikrose `_
and `@bbayles `_, with help from `many others `_.
If you have a problem or suggestion, please file a bug or pull request in this
repository. Thanks for contributing!