Rename class ContextManager to ContextWrapper, per Nick's proposal.

This commit is contained in:
Guido van Rossum 2005-07-12 16:28:56 +00:00
parent f2d367de26
commit cc0bfb59f2
1 changed files with 3 additions and 3 deletions

View File

@ -258,7 +258,7 @@ Generator Decorator
that makes it possible to use a generator that yields exactly once
to control a with-statement. Here's a sketch of such a decorator:
class ContextManager(object):
class ContextWrapper(object):
def __init__(self, gen):
self.gen = gen
@ -287,14 +287,14 @@ Generator Decorator
def contextmanager(func):
def helper(*args, **kwds):
return ContextManager(func(*args, **kwds))
return ContextWrapper(func(*args, **kwds))
return helper
This decorator could be used as follows:
@contextmanager
def opening(filename):
f = open(filename) # IOError is untouched by ContextManager
f = open(filename) # IOError is untouched by ContextWrapper
try:
yield f
finally: