Skip to main content

Collection iterator over classes

Project description

collection

Collection 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. Current version is 1.0.0

Basic usage

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


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


for element in elements:
    print(element.value())

# output
# > 1
# > 2
# > 3
# > 4
# > 5

Available methods

methods
count
json
find
where
item
first
append
items

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

pycollection-1.0.0.tar.gz (2.0 kB view hashes)

Uploaded Source

Built Distribution

pycollection-1.0.0-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

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