Collection iterator over classes
Project description
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. Current version is 1.0.2.
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
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 |
---|
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.2.tar.gz
(2.1 kB
view hashes)
Built Distribution
Close
Hashes for pycollection-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abbd1bbcd42a89d1cc070f1129b654a9b0e6e18e5dd0c1f69a98c95fb42bf2a9 |
|
MD5 | 596e3d8fc91cf94156d75e43abcb503a |
|
BLAKE2b-256 | 09b3906ed3eae4f1ed74aecccbef6bbb6104b02cd2cd15de5e081f5f7cf94e8b |