Skip to main content
PyPI Package latest release PyPI Package monthly downloads Supported versions Supported implementations Wheel packaging support Test line coverage

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+, but it is not strictly needed there since those verions’ collections modules contains good ChainMap implementations.)

The code for this package is closely derived from the Python 3.5 source code, (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:

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 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.

  • Thanks to Travis CI, successfully packaged for, and tested against, all reasonably late-model versions of Python: 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, and 3.7, as well as PyPy 5.8.0 (essentially Python 2.7.13) and PyPy3 5.10.1 (corresponding to Python 3.5.3).

  • 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 files for chainmap 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chainmap 1.0.3
File Size Uploaded
chainmap-1.0.3.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chainmap 1.0.3
File Interpreter ABI Platform
chainmap-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / chainmap-1.0.3.tar.gz

Download URL chainmap-1.0.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e42aaa4b3e2f66102a11bfd563069704bfbfd84fdcb517b564effd736bf53cd9
BLAKE2b-256 checksum
How to use checksums
c7ab268a15383b75ca3e58ce344bce165b79768e516f8e79c87cbdaba30c38e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.7.2

Release files / chainmap-1.0.3-py3-none-any.whl

Download URL chainmap-1.0.3-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22b6ccf38698c0356e65e5dfa49c98fb16e3408928b95d90e2332e2fb787988e
BLAKE2b-256 checksum
How to use checksums
f5f778ddc379d5dc2bbdcf690c3663396d8be5f2c7bc76d30012beef620272ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

3 release files

1.0.1

3 release files

1.0.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page