[Python-Dev] More on contextlib - adding back a contextmanager decorator

Nick Coghlan ncoghlan at gmail.com
Mon May 1 13:42:13 CEST 2006


Greg Ewing wrote:
> Also a thought on terminology. Even though it seems I
> may have been the person who thought it up originally,
> I'm not sure I like the term "manager". It seems rather
> wooly, and it's not clear whether a "context manager"
> is supposed to manage just one context or multiple
> contexts.

I think getting rid of __context__ should clear up most of this confusion 
(which is further evidence that Guido is making the right call). Once that 
change is made, the context expression in the with statement produces a 
context manager with __enter__ and __exit__ methods which set up and tear down 
a managed context for the body of the with statement. This is very similar to 
your later suggestion of context guard and guarded context.

I believe this is actually going back to using the terminology as you 
originally suggested it (one concrete object, one abstract concept). We really 
only got into trouble once we tried to add a second kind of concrete object 
into the mix (objects with only a __context__ method).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list