why not http://docs.python.org/3.2/library/contextlib.html#contextlib.contextmanager ?