This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

automatic typed collections in python using decorators

Project Description

This is a python library for typed containers – it makes it safer & easier to work with lists & dicts of items of the same type by providing:

  • type checks
  • container methods
  • automatic dictionary keys

Example:

import containers

@containers.container_class
class Item:
    def __init__(self, x):
        self.x = x

    @containers.container_method()
    def sum(container):
        return sum(item.x for item in container)

    @containers.container_key
    def key(self):
        return self.x

list_ = Item.container(list)
list_.append(Item(1))
list_.append(Item(2))

# items of incompatible type are rejected
with pytest.raises(TypeError):
    list_.append(3)

# container_method methods are available on the list
assert list_.sum() == 3
Release History

Release History

This version
History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

History Node

0.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
containers-0.0.3.tar.gz (2.7 kB) Copy SHA256 Checksum SHA256 Source Apr 13, 2016

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