d8s-lists


Named8s-lists JSON
Version 0.8.0 PyPI version JSON
download
home_pagehttps://github.com/democritus-project/d8s-lists
SummaryDemocritus functions for working with lists.
upload_time2021-05-07 10:55:01
maintainer
docs_urlNone
authorFloyd Hightower
requires_python
licenseGNU Lesser General Public License v3
keywords democritus utility python lists lists-utility arrays
VCS
bugtrack_url
requirements d8s-dicts more_itertools importlib-metadata
Travis-CI No Travis.
coveralls test coverage
            # Democritus Lists

[![PyPI](https://img.shields.io/pypi/v/d8s-lists.svg)](https://pypi.python.org/pypi/d8s-lists)
[![CI](https://github.com/democritus-project/d8s-lists/workflows/CI/badge.svg)](https://github.com/democritus-project/d8s-lists/actions)
[![Lint](https://github.com/democritus-project/d8s-lists/workflows/Lint/badge.svg)](https://github.com/democritus-project/d8s-lists/actions)
[![codecov](https://codecov.io/gh/democritus-project/d8s-lists/branch/main/graph/badge.svg?token=V0WOIXRGMM)](https://codecov.io/gh/democritus-project/d8s-lists)
[![The Democritus Project uses semver version 2.0.0](https://img.shields.io/badge/-semver%20v2.0.0-22bfda)](https://semver.org/spec/v2.0.0.html)
[![The Democritus Project uses black to format code](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://choosealicense.com/licenses/lgpl-3.0/)

Democritus functions<sup>[1]</sup> for working with lists.

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

We use `d8s` (pronounced "dee-eights") as an abbreviation for `democritus` (you can read more about this [here](https://github.com/democritus-project/roadmap#what-is-d8s)).

## Installation

```
pip install d8s-lists
```

## Usage

You import the library like:

```python
from d8s_lists import *
```

Once imported, you can use any of the functions listed below.

## Functions

  - ```python
    def iterable_sort_by_length(iterable: Iterable[Any], **kwargs) -> List[Any]:
        """."""
    ```
  - ```python
    def longest(iterable: Iterable[Any]) -> Any:
        """."""
    ```
  - ```python
    def shortest(iterable: Iterable[Any]) -> Any:
        """."""
    ```
  - ```python
    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."""
    ```
  - ```python
    def has_index(iterable: Sized, index: int) -> bool:
        """."""
    ```
  - ```python
    def types(iterable: Iterable[Any]) -> Iterator[Type]:
        """Return a set containing the types of all items in the list_arg."""
    ```
  - ```python
    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."""
    ```
  - ```python
    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."""
    ```
  - ```python
    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."""
    ```
  - ```python
    def deduplicate(iterable: Iterable[Any]) -> Iterator[Any]:
        """Deduplicate the iterable."""
    ```
  - ```python
    def cycle(iterable: Iterable[Any], length: Optional[int] = None) -> Iterator[Any]:
        """Cycle through the iterable as much as needed."""
    ```
  - ```python
    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)"""
    ```
  - ```python
    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)"""
    ```
  - ```python
    def iterable_has_single_item(iterable: Iterable[Any]) -> bool:
        """Return whether the iterable has a single item in it."""
    ```
  - ```python
    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."""
    ```
  - ```python
    def iterables_have_same_items(a: Sequence, b: Sequence, *args: Sequence) -> bool:
        """Return whether iterables have identical items (considering both identity and count)."""
    ```
  - ```python
    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."""
    ```
  - ```python
    def iterable_count(iterable: Iterable[Any]) -> Dict[Any, int]:
        """Count each item in the iterable."""
    ```
  - ```python
    def iterable_item_index(iterable: Sequence, item: Any) -> int:
        """Find the given item in the iterable. Return -1 if the item is not found."""
    ```
  - ```python
    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."""
    ```
  - ```python
    def duplicates(iterable: Sequence) -> Iterator[Sequence]:
        """Find duplicates in the given iterable."""
    ```
  - ```python
    def iterable_has_mixed_types(iterable: Iterable[Any]) -> bool:
        """Return whether or not the iterable has items with two or more types."""
    ```
  - ```python
    def iterable_has_single_type(iterable: Iterable[Any]) -> bool:
        """Return whether or not the iterable has items of only one type."""
    ```
  - ```python
    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

๐Ÿ‘‹ &nbsp;If you want to get involved in this project, we have some short, helpful guides below:

- [contribute to this project ๐Ÿฅ‡][contributing]
- [test it ๐Ÿงช][local-dev]
- [lint it ๐Ÿงน][local-dev]
- [explore it ๐Ÿ”ญ][local-dev]

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](https://github.com/audreyr/cookiecutter) and Floyd Hightower's [Python project template](https://github.com/fhightower-templates/python-project-template).

[contributing]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#contributing-a-pr-
[local-dev]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#local-development-



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/democritus-project/d8s-lists",
    "name": "d8s-lists",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "democritus,utility,python,lists,lists-utility,arrays",
    "author": "Floyd Hightower",
    "author_email": "floyd.hightower27@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8d/1e/5303df0a4b55f3db49805e9a34c20eecb67ea7855ac348d17ee80d7816a9/d8s_lists-0.8.0.tar.gz",
    "platform": "",
    "description": "# Democritus Lists\n\n[![PyPI](https://img.shields.io/pypi/v/d8s-lists.svg)](https://pypi.python.org/pypi/d8s-lists)\n[![CI](https://github.com/democritus-project/d8s-lists/workflows/CI/badge.svg)](https://github.com/democritus-project/d8s-lists/actions)\n[![Lint](https://github.com/democritus-project/d8s-lists/workflows/Lint/badge.svg)](https://github.com/democritus-project/d8s-lists/actions)\n[![codecov](https://codecov.io/gh/democritus-project/d8s-lists/branch/main/graph/badge.svg?token=V0WOIXRGMM)](https://codecov.io/gh/democritus-project/d8s-lists)\n[![The Democritus Project uses semver version 2.0.0](https://img.shields.io/badge/-semver%20v2.0.0-22bfda)](https://semver.org/spec/v2.0.0.html)\n[![The Democritus Project uses black to format code](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://choosealicense.com/licenses/lgpl-3.0/)\n\nDemocritus functions<sup>[1]</sup> for working with lists.\n\n[1] Democritus functions are <i>simple, effective, modular, well-tested, and well-documented</i> Python functions.\n\nWe use `d8s` (pronounced \"dee-eights\") as an abbreviation for `democritus` (you can read more about this [here](https://github.com/democritus-project/roadmap#what-is-d8s)).\n\n## Installation\n\n```\npip install d8s-lists\n```\n\n## Usage\n\nYou import the library like:\n\n```python\nfrom d8s_lists import *\n```\n\nOnce imported, you can use any of the functions listed below.\n\n## Functions\n\n  - ```python\n    def iterable_sort_by_length(iterable: Iterable[Any], **kwargs) -> List[Any]:\n        \"\"\".\"\"\"\n    ```\n  - ```python\n    def longest(iterable: Iterable[Any]) -> Any:\n        \"\"\".\"\"\"\n    ```\n  - ```python\n    def shortest(iterable: Iterable[Any]) -> Any:\n        \"\"\".\"\"\"\n    ```\n  - ```python\n    def flatten(iterable: Iterable[Any], level: int = None, **kwargs) -> Iterator[Any]:\n        \"\"\"Flatten all items in the iterable so that they are all items in the same list.\"\"\"\n    ```\n  - ```python\n    def has_index(iterable: Sized, index: int) -> bool:\n        \"\"\".\"\"\"\n    ```\n  - ```python\n    def types(iterable: Iterable[Any]) -> Iterator[Type]:\n        \"\"\"Return a set containing the types of all items in the list_arg.\"\"\"\n    ```\n  - ```python\n    def iterable_item_of_types(iterable: Iterable[Any], item_types: Iterable[type]) -> bool:\n        \"\"\"Return True if the iterable has any item that is of the item_types. Otherwise, return False.\"\"\"\n    ```\n  - ```python\n    def iterable_all_items_of_types(iterable: Iterable[Any], item_types: Iterable[type]) -> bool:\n        \"\"\"Return True if all items in the iterable are of a type given in item_types. Otherwise, return False.\"\"\"\n    ```\n  - ```python\n    def iterable_has_all_items_of_type(iterable: Iterable[Any], type_arg: type) -> bool:\n        \"\"\"Return whether or not all iterable in iterable are of the type specified by the type_arg.\"\"\"\n    ```\n  - ```python\n    def deduplicate(iterable: Iterable[Any]) -> Iterator[Any]:\n        \"\"\"Deduplicate the iterable.\"\"\"\n    ```\n  - ```python\n    def cycle(iterable: Iterable[Any], length: Optional[int] = None) -> Iterator[Any]:\n        \"\"\"Cycle through the iterable as much as needed.\"\"\"\n    ```\n  - ```python\n    def truthy_items(iterable: Iterable[Any]) -> Iterator[Any]:\n        \"\"\"Return an iterable with only elements of the given iterable which evaluate to True.\n\n    (see https://docs.python.org/3.9/library/stdtypes.html#truth-value-testing)\"\"\"\n    ```\n  - ```python\n    def nontruthy_items(iterable: Iterable[Any]) -> Iterator[Any]:\n        \"\"\"Return an iterable with only elements of the given iterable which evaluate to False.\n\n    (see https://docs.python.org/3.9/library/stdtypes.html#truth-value-testing)\"\"\"\n    ```\n  - ```python\n    def iterable_has_single_item(iterable: Iterable[Any]) -> bool:\n        \"\"\"Return whether the iterable has a single item in it.\"\"\"\n    ```\n  - ```python\n    def iterables_are_same_length(a: Sized, b: Sized, *args: Sized, debug_failure: bool = False) -> bool:\n        \"\"\"Return whether or not the given iterables are the same lengths.\"\"\"\n    ```\n  - ```python\n    def iterables_have_same_items(a: Sequence, b: Sequence, *args: Sequence) -> bool:\n        \"\"\"Return whether iterables have identical items (considering both identity and count).\"\"\"\n    ```\n  - ```python\n    def run_length_encoding(iterable: Iterable[Any]) -> Iterator[str]:\n        \"\"\"Perform run-length encoding on the given array.\n\n    See https://en.wikipedia.org/wiki/Run-length_encoding for more details.\"\"\"\n    ```\n  - ```python\n    def iterable_count(iterable: Iterable[Any]) -> Dict[Any, int]:\n        \"\"\"Count each item in the iterable.\"\"\"\n    ```\n  - ```python\n    def iterable_item_index(iterable: Sequence, item: Any) -> int:\n        \"\"\"Find the given item in the iterable. Return -1 if the item is not found.\"\"\"\n    ```\n  - ```python\n    def iterable_item_indexes(iterable: Iterable[Any], item: Any) -> Iterator[int]:\n        \"\"\"Find the given item in the iterable. Return -1 if the item is not found.\"\"\"\n    ```\n  - ```python\n    def duplicates(iterable: Sequence) -> Iterator[Sequence]:\n        \"\"\"Find duplicates in the given iterable.\"\"\"\n    ```\n  - ```python\n    def iterable_has_mixed_types(iterable: Iterable[Any]) -> bool:\n        \"\"\"Return whether or not the iterable has items with two or more types.\"\"\"\n    ```\n  - ```python\n    def iterable_has_single_type(iterable: Iterable[Any]) -> bool:\n        \"\"\"Return whether or not the iterable has items of only one type.\"\"\"\n    ```\n  - ```python\n    def iterable_replace(iterable: Iterable[Any], old_value: Any, new_value: Any) -> Iterator[Any]:\n        \"\"\"Replace all instances of the old_value with the new_value in the given iterable.\"\"\"\n    ```\n\n## Development\n\n\ud83d\udc4b &nbsp;If you want to get involved in this project, we have some short, helpful guides below:\n\n- [contribute to this project \ud83e\udd47][contributing]\n- [test it \ud83e\uddea][local-dev]\n- [lint it \ud83e\uddf9][local-dev]\n- [explore it \ud83d\udd2d][local-dev]\n\nIf you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.\n\n## Credits\n\nThis package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and Floyd Hightower's [Python project template](https://github.com/fhightower-templates/python-project-template).\n\n[contributing]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#contributing-a-pr-\n[local-dev]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#local-development-\n\n\n",
    "bugtrack_url": null,
    "license": "GNU Lesser General Public License v3",
    "summary": "Democritus functions for working with lists.",
    "version": "0.8.0",
    "project_urls": {
        "Homepage": "https://github.com/democritus-project/d8s-lists"
    },
    "split_keywords": [
        "democritus",
        "utility",
        "python",
        "lists",
        "lists-utility",
        "arrays"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aab29d2839b7da38b97afca11cd7192638b1c240f0e513b98de428420ab81357",
                "md5": "fe6d8d36d403e7827b0bbfe082a8f934",
                "sha256": "93b7f6f402af580467a058d941673dcc3911084aa58cdc95f458f58ad8d81af4"
            },
            "downloads": -1,
            "filename": "d8s_lists-0.8.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe6d8d36d403e7827b0bbfe082a8f934",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 23251,
            "upload_time": "2021-05-07T10:54:59",
            "upload_time_iso_8601": "2021-05-07T10:54:59.050782Z",
            "url": "https://files.pythonhosted.org/packages/aa/b2/9d2839b7da38b97afca11cd7192638b1c240f0e513b98de428420ab81357/d8s_lists-0.8.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d1e5303df0a4b55f3db49805e9a34c20eecb67ea7855ac348d17ee80d7816a9",
                "md5": "9413930de32a9687873d38054532fc3d",
                "sha256": "6a7709a9a64a64f77a85051d6887117ec216a2dd71d02477bcd0277e9fd4477e"
            },
            "downloads": -1,
            "filename": "d8s_lists-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9413930de32a9687873d38054532fc3d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 27395,
            "upload_time": "2021-05-07T10:55:01",
            "upload_time_iso_8601": "2021-05-07T10:55:01.354791Z",
            "url": "https://files.pythonhosted.org/packages/8d/1e/5303df0a4b55f3db49805e9a34c20eecb67ea7855ac348d17ee80d7816a9/d8s_lists-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-07 10:55:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "democritus-project",
    "github_project": "d8s-lists",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "d8s-dicts",
            "specs": [
                [
                    "==",
                    "0.*"
                ]
            ]
        },
        {
            "name": "more_itertools",
            "specs": []
        },
        {
            "name": "importlib-metadata",
            "specs": []
        }
    ],
    "lcname": "d8s-lists"
}
        
Elapsed time: 0.18160s