diff options
author | Phillip J. Eby <pje@telecommunity.com> | 2006-03-28 00:13:10 (GMT) |
---|---|---|
committer | Phillip J. Eby <pje@telecommunity.com> | 2006-03-28 00:13:10 (GMT) |
commit | 168e99f6db1a207477fa02609663b66475bfd460 (patch) | |
tree | bbab8543cf33c8604053ee8079b4be0d45b489a5 /Doc/lib/libthread.tex | |
parent | bdfd69380436bf9360f344a3823b3822cd5d6be7 (diff) | |
download | cpython-168e99f6db1a207477fa02609663b66475bfd460.zip cpython-168e99f6db1a207477fa02609663b66475bfd460.tar.gz cpython-168e99f6db1a207477fa02609663b66475bfd460.tar.bz2 |
Document objects that can be used with the ``with`` statement.
Diffstat (limited to 'Doc/lib/libthread.tex')
-rw-r--r-- | Doc/lib/libthread.tex | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Doc/lib/libthread.tex b/Doc/lib/libthread.tex index 4914948d..9e0c202 100644 --- a/Doc/lib/libthread.tex +++ b/Doc/lib/libthread.tex @@ -100,6 +100,19 @@ Return the status of the lock:\ \code{True} if it has been acquired by some thread, \code{False} if not. \end{methoddesc} +In addition to these methods, lock objects can also be used via the +\keyword{with} statement, e.g.: + +\begin{verbatim} +from __future__ import with_statement +import thread + +a_lock = thread.allocate_lock() + +with a_lock: + print "a_lock is locked while this executes" +\end{verbatim} + \strong{Caveats:} \begin{itemize} |