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