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

A.M. Kuchling amk at amk.ca
Fri Apr 21 16:51:21 CEST 2006


On Fri, Apr 21, 2006 at 07:31:35PM +1000, Nick Coghlan wrote:
> fit the new definition. So we settled on calling them "context managers" 
> instead.
 ... 
> method. Instead, the new term "manageable context" (or simply "context") 
> was introduced to mean "anything with a __context__ method". This was OK, 

Meaning that 'manageable context' objects create and destroy 'context
managers'...  My view is still that 'context manager' is a terrible
name when used alongside objects called 'contexts': the object doesn't
manage anything, and it certainly doesn't manage contexts -- in fact
it's created by 'context' objects.

Perhaps we need to do some usability tests.  Go to a local user group,
explain the 'with' statement and the necessary objects using __foo__
instead of __context__, provide three or four pairs of names, and then
ask the audience which set of names seems most sensible.

For the What's New, I'm now beginning to think the text should say
'objects that have a __context__() method', and then refer to either
contexts or context managers (whichever way the decision goes) for the
objects with enter/exit, to avoid this confusion.

--amk


More information about the Python-Dev mailing list