--- Lib/contextlib.py.orig 2010-10-08 12:50:17.246258779 +0200 +++ Lib/contextlib.py 2010-10-08 13:13:17.756555409 +0200 @@ -152,3 +152,16 @@ return self.thing def __exit__(self, *exc_info): self.thing.close() + +class Null(object): + """Helper for null context manager.""" + def __enter__(self): + return None + def __exit__(*ignored): + return False + +_null = Null() + +def null(): + """No-op context manager, executes block without doing anything else.""" + return _null