Commit 3c1983fa authored by Georg Brandl's avatar Georg Brandl

Patch #1479438: add \keyword markup for "with".

parent 3583cff5
...@@ -2149,9 +2149,9 @@ using a generator function decorated with the ...@@ -2149,9 +2149,9 @@ using a generator function decorated with the
than writing individual \method{__enter__()} and \method{__exit__()} than writing individual \method{__enter__()} and \method{__exit__()}
methods on a separate object when the state to be managed is complex. methods on a separate object when the state to be managed is complex.
With statement context objects also need to implement this method; they \keyword{with} statement context objects also need to implement this
are required to return themselves (that is, this method will simply method; they are required to return themselves (that is, this method
return \var{self}). will simply return \var{self}).
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}[with statement context]{__enter__}{self} \begin{methoddesc}[with statement context]{__enter__}{self}
......
...@@ -315,7 +315,7 @@ statement to generate exceptions may be found in section~\ref{raise}. ...@@ -315,7 +315,7 @@ statement to generate exceptions may be found in section~\ref{raise}.
\versionadded{2.5} \versionadded{2.5}
The \keyword{with} statement is used to wrap the execution of a block The \keyword{with} statement is used to wrap the execution of a block
with methods defined by a context manager or with statement context with methods defined by a context manager or \keyword{with} statement context
object (see section~\ref{context-managers}). This allows common object (see section~\ref{context-managers}). This allows common
\keyword{try}...\keyword{except}...\keyword{finally} usage patterns to \keyword{try}...\keyword{except}...\keyword{finally} usage patterns to
be encapsulated for convenient reuse. be encapsulated for convenient reuse.
...@@ -332,7 +332,7 @@ The execution of the \keyword{with} statement proceeds as follows: ...@@ -332,7 +332,7 @@ The execution of the \keyword{with} statement proceeds as follows:
\item The context expression is evaluated, to obtain a context manager. \item The context expression is evaluated, to obtain a context manager.
\item The context manger's \method{__context__()} method is \item The context manger's \method{__context__()} method is
invoked to obtain a with statement context object. invoked to obtain a \keyword{with} statement context object.
\item The context object's \method{__enter__()} method is invoked. \item The context object's \method{__enter__()} method is invoked.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment