ext-list


Nameext-list JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://github.com/sk-guritech/ext-list
SummaryThis is a utility library that extends Python's list operations.
upload_time2023-05-21 17:57:39
maintainer
docs_urlNone
authorSakaguchi Ryo
requires_python>=3.7
license
keywords list comprehension iterable code quality
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ExtList
[![PyPI version](https://badge.fury.io/py/ext-list.svg)](https://badge.fury.io/py/ext-list)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ext-list)
![GitHub](https://img.shields.io/github/license/sk-guritech/ext-list)

This library was created to improve the quality of code through list operations. It allows commonly written list comprehension operations to be called as methods and enables lists to be treated more abstractly than the built-in `list`.

Using this library reduces the number of times list comprehensions need to be written, resulting in improved overall code readability and searchability.

More information -> **[Docs: ExtList](https://sk-guritech.github.io/ext-list/)**

## Installation
```
pip install ext-list
```

## Examples
Below are some examples of features of this library.

_Note: In the following examples, the `Person` class is defined as follows._

<details>
    <summary>(class Person)</summary>

    >>> class Person:
    ...     def __init__(self, name, age):
    ...         self.__name = name
    ...         self.__age = age
    ...
    ...     def introduce(self):
    ...         return f'{self.name} is {self.age} years old.'
    ...
    ...     def get_age_n_years_ago(self, n: int) -> int:
    ...        return self.age - n
    ...
    ...     @property
    ...     def name(self):
    ...         return self.__name
    ...
    ...     @property
    ...     def age(self):
    ...         return self.__age
    ...
    ...     def __repr__(self):
    ...         return f'Person(\'{self.name}\', {self.age})'
    ...
</details>

- Extract values
    ```
    >>> person_dicts = ExtList([{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}])
    >>> person_dicts.extract('name')
    ['Alice', 'Bob']

    >>> persons = ExtList(Person('Alice', 25), Person('Bob', 30))
    >>> persons.extract(Person.name)
    ['Alice', 'Bob']

    >>> persons.extract('name')
    ['Alice', 'Bob']

    >>> persons.extract(Person.introduce)
    ['Alice is 25 years old.', 'Bob is 30 years old.']

    >>> persons.extract(Person.get_age_n_years_ago, 5)
    [20, 25]
    ```

- Get matched objects
    ```
    >>> persons = ExtList([{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}])
    >>> persons.equals('name', 'Alice')
    [{'name': 'Alice', 'age': 25}]

    >>> persons = ExtList(Person('Alice', 25), Person('Bob', 30))
    >>> persons.equals(Person.name, 'Alice')
    [Person('Alice', 25)]

    >>> persons.equals(Person.introduce, 'Bob is 30 years old.')
    [Person('Bob', 30)]
    ```

- Convert list to dict
    ```
    >>> persons = ExtList([Person('Alice', 25), Person('Bob', 30)])
    >>> persons.to_dict(Person.name)
    {'Alice': Person('Alice', 25), 'Bob': Person('Bob', 30)}
    ```

- Convert list to dict with complex keys
    ```
    >>> persons = ExtList([Person('Alice', 25), Person('Bob', 30)])
    >>> persons.to_dict_with_complex_keys([Person.name, Person.age])
    {('Alice', 25): Person('Alice', 30),
    ('Bob', 30): Person('Bob', 25)}
    ```

See the **[Docs: ExtList](https://sk-guritech.github.io/ext-list/)** for more examples !

## requirements
```
typing_extensions
```

## License
[MIT license](https://github.com/sk-guritech/ext-list/blob/master/LICENSE)

## Author
Sakaguchi Ryo ([@GuriTech](https://twitter.com/GuriTech))

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sk-guritech/ext-list",
    "name": "ext-list",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "list,comprehension,iterable,code quality",
    "author": "Sakaguchi Ryo",
    "author_email": "sakaguchi@sk-techfirm.com",
    "download_url": "https://files.pythonhosted.org/packages/13/65/b287efa84c2e25d1c272ba8fc7f13f0266fd9982a963244b1b4099a67f68/ext-list-1.1.1.tar.gz",
    "platform": null,
    "description": "# ExtList\n[![PyPI version](https://badge.fury.io/py/ext-list.svg)](https://badge.fury.io/py/ext-list)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ext-list)\n![GitHub](https://img.shields.io/github/license/sk-guritech/ext-list)\n\nThis library was created to improve the quality of code through list operations. It allows commonly written list comprehension operations to be called as methods and enables lists to be treated more abstractly than the built-in `list`.\n\nUsing this library reduces the number of times list comprehensions need to be written, resulting in improved overall code readability and searchability.\n\nMore information -> **[Docs: ExtList](https://sk-guritech.github.io/ext-list/)**\n\n## Installation\n```\npip install ext-list\n```\n\n## Examples\nBelow are some examples of features of this library.\n\n_Note: In the following examples, the `Person` class is defined as follows._\n\n<details>\n    <summary>(class Person)</summary>\n\n    >>> class Person:\n    ...     def __init__(self, name, age):\n    ...         self.__name = name\n    ...         self.__age = age\n    ...\n    ...     def introduce(self):\n    ...         return f'{self.name} is {self.age} years old.'\n    ...\n    ...     def get_age_n_years_ago(self, n: int) -> int:\n    ...        return self.age - n\n    ...\n    ...     @property\n    ...     def name(self):\n    ...         return self.__name\n    ...\n    ...     @property\n    ...     def age(self):\n    ...         return self.__age\n    ...\n    ...     def __repr__(self):\n    ...         return f'Person(\\'{self.name}\\', {self.age})'\n    ...\n</details>\n\n- Extract values\n    ```\n    >>> person_dicts = ExtList([{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}])\n    >>> person_dicts.extract('name')\n    ['Alice', 'Bob']\n\n    >>> persons = ExtList(Person('Alice', 25), Person('Bob', 30))\n    >>> persons.extract(Person.name)\n    ['Alice', 'Bob']\n\n    >>> persons.extract('name')\n    ['Alice', 'Bob']\n\n    >>> persons.extract(Person.introduce)\n    ['Alice is 25 years old.', 'Bob is 30 years old.']\n\n    >>> persons.extract(Person.get_age_n_years_ago, 5)\n    [20, 25]\n    ```\n\n- Get matched objects\n    ```\n    >>> persons = ExtList([{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}])\n    >>> persons.equals('name', 'Alice')\n    [{'name': 'Alice', 'age': 25}]\n\n    >>> persons = ExtList(Person('Alice', 25), Person('Bob', 30))\n    >>> persons.equals(Person.name, 'Alice')\n    [Person('Alice', 25)]\n\n    >>> persons.equals(Person.introduce, 'Bob is 30 years old.')\n    [Person('Bob', 30)]\n    ```\n\n- Convert list to dict\n    ```\n    >>> persons = ExtList([Person('Alice', 25), Person('Bob', 30)])\n    >>> persons.to_dict(Person.name)\n    {'Alice': Person('Alice', 25), 'Bob': Person('Bob', 30)}\n    ```\n\n- Convert list to dict with complex keys\n    ```\n    >>> persons = ExtList([Person('Alice', 25), Person('Bob', 30)])\n    >>> persons.to_dict_with_complex_keys([Person.name, Person.age])\n    {('Alice', 25): Person('Alice', 30),\n    ('Bob', 30): Person('Bob', 25)}\n    ```\n\nSee the **[Docs: ExtList](https://sk-guritech.github.io/ext-list/)** for more examples !\n\n## requirements\n```\ntyping_extensions\n```\n\n## License\n[MIT license](https://github.com/sk-guritech/ext-list/blob/master/LICENSE)\n\n## Author\nSakaguchi Ryo ([@GuriTech](https://twitter.com/GuriTech))\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This is a utility library that extends Python's list operations.",
    "version": "1.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/sk-guritech/ext-list/issues",
        "Homepage": "https://github.com/sk-guritech/ext-list"
    },
    "split_keywords": [
        "list",
        "comprehension",
        "iterable",
        "code quality"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "becc5a4c86e2efe8bf9157ca2202b2d758bf7f9ff659b10bfd4ef897b6ed1a29",
                "md5": "c2c03734f28d55a75e68c4c1cf2197b8",
                "sha256": "927c2b0a6c1a440323c835b3cf2e7410e9ce828a99acec9efc676255859256c5"
            },
            "downloads": -1,
            "filename": "ext_list-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c2c03734f28d55a75e68c4c1cf2197b8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 15416,
            "upload_time": "2023-05-21T17:57:36",
            "upload_time_iso_8601": "2023-05-21T17:57:36.534070Z",
            "url": "https://files.pythonhosted.org/packages/be/cc/5a4c86e2efe8bf9157ca2202b2d758bf7f9ff659b10bfd4ef897b6ed1a29/ext_list-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1365b287efa84c2e25d1c272ba8fc7f13f0266fd9982a963244b1b4099a67f68",
                "md5": "0a2d5704f1d746769a1a1397ecf87d2c",
                "sha256": "147019c34b0cccef6c771f5f5e9a949c4f90edd09984438ae46e632f5a62e8a3"
            },
            "downloads": -1,
            "filename": "ext-list-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0a2d5704f1d746769a1a1397ecf87d2c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10955,
            "upload_time": "2023-05-21T17:57:39",
            "upload_time_iso_8601": "2023-05-21T17:57:39.593270Z",
            "url": "https://files.pythonhosted.org/packages/13/65/b287efa84c2e25d1c272ba8fc7f13f0266fd9982a963244b1b4099a67f68/ext-list-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-21 17:57:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sk-guritech",
    "github_project": "ext-list",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "tox": true,
    "lcname": "ext-list"
}
        
Elapsed time: 0.08023s