README.rst
1==============
2More Itertools
3==============
4
5.. image:: https://coveralls.io/repos/github/erikrose/more-itertools/badge.svg?branch=master
6 :target: https://coveralls.io/github/erikrose/more-itertools?branch=master
7
8Python's ``itertools`` library is a gem - you can compose elegant solutions
9for a variety of problems with the functions it provides. In ``more-itertools``
10we collect additional building blocks, recipes, and routines for working with
11Python iterables.
12
13Getting started
14===============
15
16To get started, install the library with `pip <https://pip.pypa.io/en/stable/>`_:
17
18.. code-block:: shell
19
20 pip install more-itertools
21
22The recipes from the `itertools docs <https://docs.python.org/3/library/itertools.html#itertools-recipes>`_
23are included in the top-level package:
24
25.. code-block:: python
26
27 >>> from more_itertools import flatten
28 >>> iterable = [(0, 1), (2, 3)]
29 >>> list(flatten(iterable))
30 [0, 1, 2, 3]
31
32Several new recipes are available as well:
33
34.. code-block:: python
35
36 >>> from more_itertools import chunked
37 >>> iterable = [0, 1, 2, 3, 4, 5, 6, 7, 8]
38 >>> list(chunked(iterable, 3))
39 [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
40
41 >>> from more_itertools import spy
42 >>> iterable = (x * x for x in range(1, 6))
43 >>> head, iterable = spy(iterable, n=3)
44 >>> list(head)
45 [1, 4, 9]
46 >>> list(iterable)
47 [1, 4, 9, 16, 25]
48
49
50
51For the full listing of functions, see the `API documentation <https://more-itertools.readthedocs.io/en/latest/api.html>`_.
52
53Development
54===========
55
56``more-itertools`` is maintained by `@erikrose <https://github.com/erikrose>`_
57and `@bbayles <https://github.com/bbayles>`_, with help from `many others <https://github.com/erikrose/more-itertools/graphs/contributors>`_.
58If you have a problem or suggestion, please file a bug or pull request in this
59repository. Thanks for contributing!
60