Python Package to Manage List of Objects
I need to create this package to manage lists of same objects.
pip install https://github.com/dabenny/ListOfObjects
On my work often I have a bunch of objects with properties and methods as the following:
class Box:
name = 'Baox'
money = 23
def test(self):
print('I''m a Box')
I would like to manage these objects as a list but:
from listofobj import ListOfObj
test_list = ListOfObj([Box() for n in range(1,5)])
now I can access properties and methods of each objects within the list:
test_list.name # -> return a list of Strings
test_list.money # -> return a list of Int
# I can perfom operation on the objects properties:
sum(test_list.money) # -> total money in the Boxes
# I can call object methods on each member of the list:
test_list.test() # -> print 'I''m a Box' for each object in list
# I can Slice the list by object properties:
test_list[test_list.money > 2] # Return the filtered ListOfObj
-
0.9.0
- First Public Release
Daniele Beninato – @dbeninato – db.stuff+github at outlook.it
Distributed under the GNU GENERAL PUBLIC LICENSE license. See LICENSE
for more information.
- Fork it (https://github.com/dabenny/ListOfObjects/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request