Nick Coghlan  committed f81cd7e

Fix an error in the last contextlib.closing example

  • Participants
  • Parent commits 8839ea9
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Doc/lib/libcontextlib.tex

 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.
 from __future__ import with_statement
 from contextlib import closing
 class MyClass:
     def close(self):
         print "Closing", self
-    __context__ = closing
+    def __context__(self):
+        return closing(self)
 >>> with MyClass() as x:
 ...     print "Hello from", x