pycollection


Namepycollection JSON
Version 1.0.6 PyPI version JSON
download
home_page
SummaryCollection iterator over classes
upload_time2022-12-24 01:17:22
maintainer
docs_urlNone
authorCristian Guzmán
requires_python
license
keywords python collection laravel iterator pycollection
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# pycollection

pycollection is an amazing library that allows you to iterate through a list, but it returns a transformed item. It has a lot of methods to interact with the collection. It works similar than laravel collections.

## Instalation

`pip install pycollection`

## Basic usage

    from pycollection import collection

    class NumberCollection(Collection):

        def item(self, item):
            return Number(item)


    class Number:

        def __init__(self, item):
            self._item = item

        def value(self):
            return self._item

        def squared(self):
            return self._item * self._item


    numbers = NumberCollection([1,2,3,4,5])


    for number in numbers:
        print(number.squared())

    # output
    # > 1
    # > 4
    # > 9
    # > 16
    # > 25

As you can see, it allows for an easy-to-read syntax for navigating between lists and their elements, since you can provide new functionality to both.

## Available methods

| methods                        | action                                                    |
|----------------------------| -------------------------------------------------- |
| count()                          | gets the number of total elements in the list  |
| json()                            | jsonifies the list                                     |
| find(callaback: Callable)  | returns the first item that match with the callback |
| where(callback: Callable) | returns a new collection that meets the callback |
| item(element)    | transforms each of the elements of the list when it is iterated over it |
| first()                           | gets the first item of the list                      |
| append(element)             | add a new element to the list                        |
| items()                  | retrieves the collection list |
| random()                      | retrieves a random item from the collection      |
| get(index:int)                | retrieves an element according to the given index |


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pycollection",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,collection,laravel,iterator,pycollection",
    "author": "Cristian Guzm\u00e1n",
    "author_email": "<cristian.guzman.contacto@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d0/a2/23c64470ec0be53f29af6d8c623cd550f2abdd3009fe69a3e80d3edd0a21/pycollection-1.0.6.tar.gz",
    "platform": null,
    "description": "\n# pycollection\n\npycollection is an amazing library that allows you to iterate through a list, but it returns a transformed item. It has a lot of methods to interact with the collection. It works similar than laravel collections.\n\n## Instalation\n\n`pip install pycollection`\n\n## Basic usage\n\n    from pycollection import collection\n\n    class NumberCollection(Collection):\n\n        def item(self, item):\n            return Number(item)\n\n\n    class Number:\n\n        def __init__(self, item):\n            self._item = item\n\n        def value(self):\n            return self._item\n\n        def squared(self):\n            return self._item * self._item\n\n\n    numbers = NumberCollection([1,2,3,4,5])\n\n\n    for number in numbers:\n        print(number.squared())\n\n    # output\n    # > 1\n    # > 4\n    # > 9\n    # > 16\n    # > 25\n\nAs you can see, it allows for an easy-to-read syntax for navigating between lists and their elements, since you can provide new functionality to both.\n\n## Available methods\n\n| methods                        | action                                                    |\n|----------------------------| -------------------------------------------------- |\n| count()                          | gets the number of total elements in the list  |\n| json()                            | jsonifies the list                                     |\n| find(callaback: Callable)  | returns the first item that match with the callback |\n| where(callback: Callable) | returns a new collection that meets the callback |\n| item(element)    | transforms each of the elements of the list when it is iterated over it |\n| first()                           | gets the first item of the list                      |\n| append(element)             | add a new element to the list                        |\n| items()                  | retrieves the collection list |\n| random()                      | retrieves a random item from the collection      |\n| get(index:int)                | retrieves an element according to the given index |\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Collection iterator over classes",
    "version": "1.0.6",
    "split_keywords": [
        "python",
        "collection",
        "laravel",
        "iterator",
        "pycollection"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "52a49bac44c3fe1dbf2bd8b29e8f4e5e",
                "sha256": "984469c821964cce24561215feb7f1542cc59aa7f15f198153cd22809ba5fbf8"
            },
            "downloads": -1,
            "filename": "pycollection-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "52a49bac44c3fe1dbf2bd8b29e8f4e5e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5087,
            "upload_time": "2022-12-24T01:17:20",
            "upload_time_iso_8601": "2022-12-24T01:17:20.911004Z",
            "url": "https://files.pythonhosted.org/packages/7d/a6/c164e3b2870cc577a6515781b50e8bbc09f443d4af51c3a08783992779e5/pycollection-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "fe51fccb1e53f67f5544806fbcc10547",
                "sha256": "7a24e9881a5f286848ee6ea6bf73e5c9170dc45bffab8a891a9d15f6d086cbbb"
            },
            "downloads": -1,
            "filename": "pycollection-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "fe51fccb1e53f67f5544806fbcc10547",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2437,
            "upload_time": "2022-12-24T01:17:22",
            "upload_time_iso_8601": "2022-12-24T01:17:22.484682Z",
            "url": "https://files.pythonhosted.org/packages/d0/a2/23c64470ec0be53f29af6d8c623cd550f2abdd3009fe69a3e80d3edd0a21/pycollection-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-24 01:17:22",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "pycollection"
}
        
Elapsed time: 0.02246s