Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

python 3 collections framework

Project Description

pycol

pycol is a collections framework for python 3+ usable in a fluent way. Inspired by the eclipse-collections project. All collections methods are using generators for lazy evaluation.

Examples

from pycol.factory import iterable, select, each, map
import json

# 1. reject all elements lower than 20 == [88, 22]
# 2. divide each of them by 2 == [44, 11]
# 3. evaluate if they all are greater than 10 == True (final result)
iterable([1, 88, 12, 10, 22]).reject(operator.lt, 20).map(lambda el: el / 2).all_satisfy(operator.gt, 10)

# 1. select all int greater than 10 == [108, 22]
# 2. print them
select([108, 1, 10, 22, 'foo', -15], lambda el: isinstance(el, int) and el > 10).each(print)

# print indented json output of each dictionary in the list:
map([{'a': 1, 'b': {'b1': 10, 'b2': 11}}, {'foo': 'bar'}], json.dumps, indent=2).each(print)

Tests

See test/test_collections.py.

To run the tests go to the project parent directory then run python -m pycol.test.test_collections

Coming soon…

  • Implementation for dictionaries
  • Add more functions like group_by, …
  • Leverage async generator
Release History

Release History

This version
History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pycol-1.0.2-py3-none-any.whl (5.3 kB) Copy SHA256 Checksum SHA256 py3 Wheel Apr 21, 2017
pycol-1.0.2.tar.gz (4.9 kB) Copy SHA256 Checksum SHA256 Source Apr 21, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting