summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2006-04-26 11:50:04 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2006-04-26 11:50:04 (GMT)
commit790c3c13774eccc128e83b1545ce63c19bc81c0c (patch)
tree1a734b73dbd02236e88d193a1124759fafdfa26d /Doc
parent9cc3b1ccef8f348ebfc36a13ec54e78423e9b4ff (diff)
downloadcpython-790c3c13774eccc128e83b1545ce63c19bc81c0c.zip
cpython-790c3c13774eccc128e83b1545ce63c19bc81c0c.tar.gz
cpython-790c3c13774eccc128e83b1545ce63c19bc81c0c.tar.bz2
Fix an error in the last contextlib.closing example
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libcontextlib.tex6
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/lib/libcontextlib.tex b/Doc/lib/libcontextlib.tex
index 7f07b37..9ff8524 100644
--- a/Doc/lib/libcontextlib.tex
+++ b/Doc/lib/libcontextlib.tex
@@ -149,8 +149,7 @@ occurs, \code{page.close()} will be called when the \keyword{with}
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 @@ 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