[Python-Dev] Why are contexts also managers? (wasr45544 -peps/trunk/pep-0343.txt)

Nick Coghlan ncoghlan at gmail.com
Mon Apr 24 04:49:33 CEST 2006


Just van Rossum wrote:
> Baptiste Carvello wrote:
> 
>> Terry Reedy a écrit :
>>> So I propose that the context maker be called just that: 'context
>>> maker'. That should pretty clearly not be the context that manages
>>> the block execution.
>>>
>> +1 for context maker. In fact, after reading the begining of the
>> thread, I came up with the very same idea.
> 
> Or maybe "context factory"?

That would be fine if we used __call__ to retrieve the context manager - but 
"factory" is too tightly bound to "factory function" in my mind.

I'm going to try a pass through the docs using "context specifier", which 
gives three separate terms:

   - context specifier:
      An object with a __context__ method that produces a context manager 
object to manipulate the runtime context
   - context manager:
      An object with __enter__ and __exit__ methods that manipulate the 
runtime context.
   - context (or runtime context):
      The actual changes made to the runtime state by the context manager 
based on the current state of the context specifier

This removes the ambiguity between "context object" and "runtime context".

Cheers,
Nick.

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


More information about the Python-Dev mailing list