[Python-Dev] Updated context management documentation (original) (raw)

Delaney, Timothy (Tim) tdelaney at avaya.com
Wed Apr 26 00:49:05 CEST 2006


Nick Coghlan wrote:

(An idea that just occurred to me in writing this email is "managed context". That's a lot less clumsy, and fits with the context manager idea.

+1

Context expressions In response to a comment Aahz made, I tweaked the language reference to explicitly refer to the expression in the with statement as a "context expression". The result of the context expression must then be a context manager in order for the with statement to operate correctly.

+1

Dealing with decimal.ContextManager (decimal.ManagedContext would definitely look better. . .)

+1

Dealing with contextlib.contextmanager As recently suggested (by Terry, IIRC), I renamed this to contextlib.contextfactory, as the decorator creates a factory function for producing with statement context objects.

+1

Dealing with contextlib.GeneratorContextManager I renamed this to contextlib.GeneratorContext. The fact that it's in the contextlib module provides sufficient context to indicate that this is a with statement context object, so I could avoid the clumsy naming that was needed in the decimal module.

Might still be better to name this as contextlib.ManagedGeneratorContext (or contextlib.GeneratorManagedContext, but I think the former works better).

This has been a long, tiring set of threads, but I think the end result is an improvement (particularly contextlib.contextfactory).

Tim Delaney



More information about the Python-Dev mailing list