Nick Coghlan wrote: > OK, here's some draft documentation using Phillip's context > terminology. I think it works very well. > > """ > With Statements and Context Management > > A frequent need in programming is to ensure a particular action is > taken after a specific section of code has been executed (such as > closing a file or releasing a lock). The tool to achieve this in > Python is to use the 'with' statement along with the appropriate > context manager. Context managers ensure a particular action is taken > to establish the context before the contained suite is entered, and a > second action to clean up the context when the suite is exited. > > The precise behaviour of the 'with' statement is governed by the > supplied context manager - an object which supports the context > management protocol. This protocol consists of two methods:
May I suggest that you use a different name than "context" for this ?! The term "context" is way to broad for the application scopes that you have in mind here (like e.g. managing a resource in a multi-threaded application). The PEP talks about "blocks", which is a much more precise term for what "with" is going to implement, so I'd suggest to call these thingies "block managers". Thanks, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 08 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com