Registry / data / more-itertools

more-itertools

JSON →
library10.8.0pypypi✓ verified 49d ago

A Python package offering additional routines for working with iterables, extending beyond the standard itertools module. Current version: 10.8.0. Maintained with regular updates to enhance functionality and performance.

data
pip install more-itertools
Install & Compatibility
Where this runs
tested against v11.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.040s · 18.3MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.6s · import 0.036s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

chunked
from more_itertools import chunked
Ensure correct import path to access the 'chunked' function.
windowed
from more_itertools import windowed
Ensure correct import path to access the 'windowed' function.

Demonstrates the 'chunked' function to divide an iterable into chunks of specified size.

from more_itertools import chunked iterable = [0, 1, 2, 3, 4, 5, 6, 7, 8] result = list(chunked(iterable, 3)) print(result) # Output: # [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
Debug
Known issues
breakingPython 3.7 support dropped in version 10.0.0 due to its end of life on 2023-06-27.
fix
Upgrade to Python 3.8 or later.
affects: 10.0.0
breakingThe 'first_true()' function now returns 'None' by default, changing its previous behavior.
fix
Update code to handle 'None' as a default return value.
affects: 5.0.0
deprecatedThe 'batched()' function is now an alias for 'itertools.batched' in Python 3.12 and later.
fix
Use 'itertools.batched' directly in Python 3.12+.
affects: 10.0.0
gotchaThe 'chunked()' and 'sliced()' functions now accept a 'strict' parameter, affecting their behavior.
fix
Review and adjust usage of 'strict' parameter in 'chunked()' and 'sliced()' functions.
affects: 10.7.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'more_itertools'
The 'more-itertools' package is not installed in your Python environment.
fix
Install the package using pip: `pip install more-itertools`
AttributeError: module 'more_itertools' has no attribute '__version__'
The `more_itertools` module does not expose its version via a `__version__` attribute directly within the module itself, unlike some other packages.
fix
To get the installed version, use `pkg_resources` or `importlib.metadata` (Python 3.8+): `import pkg_resources; pkg_resources.get_distribution('more-itertools').version` or `import importlib.metadata; importlib.metadata.version('more-itertools')`
ImportError: cannot import name 'pairwise' from 'itertools'
The `pairwise` function was added to the standard `itertools` module in Python 3.10. If you are using an older Python version (e.g., 3.9 or below), `pairwise` is only available in the `more-itertools` library.
fix
Either upgrade your Python version to 3.10 or newer, or import `pairwise` from `more_itertools`: `from more_itertools import pairwise` (after ensuring `more-itertools` is installed).
ValueError: chunked(): incomplete batch
This error occurs when using `more_itertools.chunked()` (or `sliced()`) with `strict=True`, and the length of the input iterable is not perfectly divisible by the chunk size `n`.
fix
Either ensure the input iterable's length is a multiple of `n`, or remove `strict=True` to allow the last chunk to be shorter, or handle incomplete batches by setting `incomplete='fill'` or `incomplete='ignore'` (for `grouper`).
Upgrade
Version history
11.1.0latest on PyPI
Audit
Dependencies
itertoolsrequiredStandard library module providing foundational iterable functions.
Agent activity
11 hits · last 30 days
node
4
seranking-bot
3
ahrefsbot
2
Amazon
1
Resources