Skip to main content

Democritus functions for working with lists.

Project description

Democritus Lists

PyPI CI Lint codecov The Democritus Project uses semver version 2.0.0 The Democritus Project uses black to format code License: LGPL v3

Democritus functions[1] for working with lists.

[1] Democritus functions are simple, effective, modular, well-tested, and well-documented Python functions.

We use d8s as an abbreviation for democritus (you can read more about this here).

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

d8s_lists-0.6.2.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

d8s_lists-0.6.2-py2.py3-none-any.whl (23.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file d8s_lists-0.6.2.tar.gz.

File metadata

  • Download URL: d8s_lists-0.6.2.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for d8s_lists-0.6.2.tar.gz
Algorithm Hash digest
SHA256 ded62493d6b18bed6594ac77ac059bfb383d1ea323caa184ae185e9e2c579d6c
MD5 cb321cbeaa28e7235c5ddf913493e089
BLAKE2b-256 968628b92d77731c35e829997cf8ed7a7b4a485613220464245183f9395423de

See more details on using hashes here.

File details

Details for the file d8s_lists-0.6.2-py2.py3-none-any.whl.

File metadata

  • Download URL: d8s_lists-0.6.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for d8s_lists-0.6.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a46175dbd2d2c418152ea748837533deb6e4d7b94a5702dcf70e71ec21478116
MD5 ba8979e6de9db83d65fc16faee3cb56c
BLAKE2b-256 a707a4b0dbc91adbf44f927e7c42f6853e6218448b6187b203e292dae9e890d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page