Sometimes I need a dummy context manager that does nothing. It can then be used as a stand-in for a more useful, but optional, context manager. For example:
ctx_
For Python 2.7+ , you can use
import contextlib with (lambda noop_func: contextlib.contextmanager(noop_func))(lambda: (yield))(): print("hi")