[Python-checkins] r45727 - python/trunk/Doc/lib/libcontextlib.tex

nick.coghlan python-checkins at python.org
Wed Apr 26 13:50:05 CEST 2006


Author: nick.coghlan
Date: Wed Apr 26 13:50:04 2006
New Revision: 45727

Modified:
   python/trunk/Doc/lib/libcontextlib.tex
Log:
Fix an error in the last contextlib.closing example

Modified: python/trunk/Doc/lib/libcontextlib.tex
==============================================================================
--- python/trunk/Doc/lib/libcontextlib.tex	(original)
+++ python/trunk/Doc/lib/libcontextlib.tex	Wed Apr 26 13:50:04 2006
@@ -149,8 +149,7 @@
 block is exited.
 
 Context managers with a close method can use this context factory
-directly without needing to implement their own
-\method{__context__()} method.
+to easily implement their own \method{__context__()} method.
 \begin{verbatim}
 from __future__ import with_statement
 from contextlib import closing
@@ -158,7 +157,8 @@
 class MyClass:
     def close(self):
         print "Closing", self
-    __context__ = closing
+    def __context__(self):
+        return closing(self)
 
 >>> with MyClass() as x:
 ...     print "Hello from", x


More information about the Python-checkins mailing list