Democritus Lists
Democritus functions[1] for working with lists.
[1] Democritus functions are simple, effective, modular, well-tested, and well-documented Python functions.
We use d8s (pronounced "dee-eights") as an abbreviation for democritus (you can read more about this here).
Installation
pip install d8s-lists
Usage
You import the library like:
from d8s_lists import *
Once imported, you can use any of the functions listed below.
Functions
-
def iterable_sort_by_length(iterable: Iterable[Any], **kwargs) -> List[Any]: """."""
-
def longest(iterable: Iterable[Any]) -> Any: """."""
-
def shortest(iterable: Iterable[Any]) -> Any: """."""
-
def flatten(iterable: Iterable[Any], level: int = None, **kwargs) -> Iterator[Any]: """Flatten all items in the iterable so that they are all items in the same list."""
-
def has_index(iterable: Sized, index: int) -> bool: """."""
-
def types(iterable: Iterable[Any]) -> Iterator[Type]: """Return a set containing the types of all items in the list_arg."""
-
def iterable_item_of_types(iterable: Iterable[Any], item_types: Iterable[type]) -> bool: """Return True if the iterable has any item that is of the item_types. Otherwise, return False."""
-
def iterable_all_items_of_types(iterable: Iterable[Any], item_types: Iterable[type]) -> bool: """Return True if all items in the iterable are of a type given in item_types. Otherwise, return False."""
-
def iterable_has_all_items_of_type(iterable: Iterable[Any], type_arg: type) -> bool: """Return whether or not all iterable in iterable are of the type specified by the type_arg."""
-
def deduplicate(iterable: Iterable[Any]) -> Iterator[Any]: """Deduplicate the iterable."""
-
def cycle(iterable: Iterable[Any], length: Optional[int] = None) -> Iterator[Any]: """Cycle through the iterable as much as needed."""
-
def truthy_items(iterable: Iterable[Any]) -> Iterator[Any]: """Return an iterable with only elements of the given iterable which evaluate to True. (see https://docs.python.org/3.9/library/stdtypes.html#truth-value-testing)"""
-
def nontruthy_items(iterable: Iterable[Any]) -> Iterator[Any]: """Return an iterable with only elements of the given iterable which evaluate to False. (see https://docs.python.org/3.9/library/stdtypes.html#truth-value-testing)"""
-
def iterable_has_single_item(iterable: Iterable[Any]) -> bool: """Return whether the iterable has a single item in it."""
-
def iterables_are_same_length(a: Sized, b: Sized, *args: Sized, debug_failure: bool = False) -> bool: """Return whether or not the given iterables are the same lengths."""
-
def iterables_have_same_items(a: Sequence, b: Sequence, *args: Sequence) -> bool: """Return whether iterables have identical items (considering both identity and count)."""
-
def run_length_encoding(iterable: Iterable[Any]) -> Iterator[str]: """Perform run-length encoding on the given array. See https://en.wikipedia.org/wiki/Run-length_encoding for more details."""
-
def iterable_count(iterable: Iterable[Any]) -> Dict[Any, int]: """Count each item in the iterable."""
-
def iterable_item_index(iterable: Sequence, item: Any) -> int: """Find the given item in the iterable. Return -1 if the item is not found."""
-
def iterable_item_indexes(iterable: Iterable[Any], item: Any) -> Iterator[int]: """Find the given item in the iterable. Return -1 if the item is not found."""
-
def duplicates(iterable: Sequence) -> Iterator[Sequence]: """Find duplicates in the given iterable."""
-
def iterable_has_mixed_types(iterable: Iterable[Any]) -> bool: """Return whether or not the iterable has items with two or more types."""
-
def iterable_has_single_type(iterable: Iterable[Any]) -> bool: """Return whether or not the iterable has items of only one type."""
-
def iterable_replace(iterable: Iterable[Any], old_value: Any, new_value: Any) -> Iterator[Any]: """Replace all instances of the old_value with the new_value in the given iterable."""
Development
👋 If you want to get involved in this project, we have some short, helpful guides below:
If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.
Credits
This package was created with Cookiecutter and Floyd Hightower's Python project template.
Release files for d8s-lists 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| d8s_lists-0.9.0.tar.gz | 93.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| d8s_lists-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 114.1 kB
Release files / d8s_lists-0.9.0.tar.gz
| Download URL | d8s_lists-0.9.0.tar.gz |
|---|---|
| Size | 93.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5e8a732a273f16cfaf134e9a9e3696a019b4f1c87d59195bffc0a8091514e87
|
|
BLAKE2b-256 checksum How to use checksums |
74d0cbd48be2be14a054b45355b247821c8adcde0f78517ca76489212a386288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.
Transparency logRelease files / d8s_lists-0.9.0-py3-none-any.whl
| Download URL | d8s_lists-0.9.0-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a478f3820acb8ee575614e2e0ed0cec23cabfa3c02090d47edea7b5c2f0cc658
|
|
BLAKE2b-256 checksum How to use checksums |
45373cc5fb56d9603a573576e4d34033820910a18a07c7ba2aa98de024251f02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.
Transparency log