contextlib

Utilities for with-statement contexts. See PEP 343.

Functions

contextmanager(func) @contextmanager decorator.
nested(*args, **kwds) Combine multiple context managers into a single nested context manager.
warn Issue a warning, or maybe ignore it or raise an exception.
wraps(wrapped[, assigned, updated]) Decorator factory to apply update_wrapper() to a wrapper function

Classes

GeneratorContextManager(gen) Helper for @contextmanager decorator.
closing(thing) Context to automatically close something at the end of a block.