IPython Documentation

Table Of Contents

Previous topic


Next topic


This Page


Module: utils.nested_context

Backwards compatibility - we use contextlib.nested to support Python 2.6, but it’s removed in Python 3.2.

IPython.utils.nested_context.nested(*args, **kwds)

Combine multiple context managers into a single nested context manager.

This function has been deprecated in favour of the multiple manager form of the with statement.

The one advantage of this function over the multiple manager form of the with statement is that argument unpacking allows it to be used with a variable number of context managers as follows:

with nested(*managers):