More routines for operating on iterables, beyond itertools
Project description
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.
Getting started
To get started, install the library with pip:
pip install more-itertools
The recipes from the itertools docs are included in the top-level package:
>>> from more_itertools import flatten
>>> iterable = [(0, 1), (2, 3)]
>>> list(flatten(iterable))
[0, 1, 2, 3]
Several new recipes are available as well:
>>> 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.
Links elsewhere
Blog posts about more-itertools:
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!
Version History
The version history can be found in documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file more-itertools-10.1.0.tar.gz
.
File metadata
- Download URL: more-itertools-10.1.0.tar.gz
- Upload date:
- Size: 111.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 626c369fa0eb37bac0291bce8259b332fd59ac792fa5497b59837309cd5b114a |
|
MD5 | 3651461253e7d206073affb491b5c6e0 |
|
BLAKE2b-256 | 2d733557e45746fcaded71125c0a1c0f87616e8258c78391f0c365bf97bbfc99 |
File details
Details for the file more_itertools-10.1.0-py3-none-any.whl
.
File metadata
- Download URL: more_itertools-10.1.0-py3-none-any.whl
- Upload date:
- Size: 55.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64e0735fcfdc6f3464ea133afe8ea4483b1c5fe3a3d69852e6503b43a0b222e6 |
|
MD5 | 7f6a73b009c706d5bb0d449ff5c7f65b |
|
BLAKE2b-256 | 5acb6dce742ea14e47d6f565589e859ad225f2a5de576d7696e0623b784e226b |