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!

Backport/clone of ChainMap for py26, py32, and pypy3.

Project Description

This module is a polyfill, implementing ChainMap for reasonably-recent versions of Python that do not have collections.ChainMap–namely, Python 2.6, Python 3.2, and PyPy3 releases based on Python 3.2. (It will also work as expected on Python 2.7, PyPy, and Python 3.3 and higher, but it is not needed there since those verions’ collections modules contains a ChainMap implementation.)

The code for this package is closely derived from the Python 3.5 source code at hg.python.org, (especially the collections and reprlib modules). Several changes have been made to ensure Python 2.6 compatibility, and tests and packaging have been added.

Typical usage:

from chainmap import ChainMap

If you prefer to preferentially import from the Python standard library when ChainMap is available there, this will do the trick:

try:
    from collections import ChainMap
except ImportError:
    from chainmap import ChainMap

Please see the standard documentation for details on how to use ChainMap.

If you’re not sure why someone would use a ChainMap, they are useful for managing “nested” contexts and “overlays.” See e.g. my options, quoter, and say packages, which use them quite extensively for flexible option handling. You can find similar uses in the Context class of Django’s template engine.

Notes

  • Automated multi-version testing managed with pytest, pytest-cov, coverage, and tox. Packaging linting with pyroma.
  • Successfully packaged for, and tested against, all late-model versions of Python: 2.6, 2.7, 3.2, 3.3, 3.4, and 3.5 as well as PyPy 2.6.1 (based on 2.7.10) and PyPy3 2.4.0 (based on 3.2.5).
  • The author, Jonathan Eunice or @jeunice on Twitter welcomes your comments and suggestions.

Installation

To install or upgrade to the latest version:

pip install -U chainmap

To easy_install under a specific Python version (3.3 in this example):

python3.3 -m easy_install --upgrade chainmap

(You may need to prefix these with sudo to authorize installation. In environments without super-user privileges, you may want to use pip’s --user option, to install only for a single user, rather than system-wide.)

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
chainmap-1.0.2-py2.py3-none-any.whl (7.5 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Sep 14, 2015
chainmap-1.0.2.tar.gz (6.4 kB) Copy SHA256 Checksum SHA256 Source Sep 14, 2015
chainmap-1.0.2.zip (12.4 kB) Copy SHA256 Checksum SHA256 Source Sep 14, 2015

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