contextlib2 — Updated utilities for context management — contextlib2 21.6.0 documentation (original) (raw)

This module provides backports of features in the latest version of the standard library’s contextlib module to earlier Python versions. It also serves as a real world proving ground for potential future enhancements to that module.

Like contextlib, this module provides utilities for common tasks involving the with and async with statements.

Additions Relative to the Standard Library

This module is primarily a backport of the Python 3.10 version ofcontextlib to earlier releases. The async context management features require asynchronous generator support in the language runtime, so the oldest supported version is now Python 3.6 (contextlib2 0.6.0 and earlier support older Python versions by omitting all asynchronous features).

This module is also a proving ground for new features not yet part of the standard library. There are currently no such features in the module.

Finally, this module contains some deprecated APIs which never graduated to standard library inclusion. These interfaces are no longer documented, but may still be present in the code (emitting DeprecationWarning if used).

Obtaining the Module

This module can be installed directly from the Python Package Index withpip:

Alternatively, you can download and unpack it manually from the contextlib2 PyPI page.

There are no operating system or distribution specific versions of this module - it is a pure Python module that should work on all platforms.

Supported Python versions are currently 3.6+.

Development and Support

contextlib2 is developed and maintained on GitHub. Problems and suggested improvements can be posted to the issue tracker.

Release History

21.6.0 (2021-06-27)

0.6.0.post1 (2019-10-10)

0.6.0 (2019-09-21)

0.5.5 (2017-04-25)

0.5.4 (2016-07-31)

0.5.3 (2016-05-02)

0.5.2 (2016-05-02)

0.5.1 (2016-01-13)

0.5.0 (2016-01-12)

0.4.0 (2012-05-05)

0.3.1 (2012-01-17)

0.3 (2012-01-04)

0.2 (2011-12-15)

0.1 (2011-12-13)