summaryrefslogtreecommitdiff
path: root/Doc/lib/libdecimal.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/lib/libdecimal.tex')
-rw-r--r--Doc/lib/libdecimal.tex14
1 files changed, 5 insertions, 9 deletions
diff --git a/Doc/lib/libdecimal.tex b/Doc/lib/libdecimal.tex
index 68748f6fe7..b046aa31f6 100644
--- a/Doc/lib/libdecimal.tex
+++ b/Doc/lib/libdecimal.tex
@@ -448,27 +448,23 @@ active context.
\begin{funcdesc}{localcontext}{\optional{c}}
Return a context manager that will set the current context for
- the active thread to a copy of \var{c} on entry to the with statement
- and restore the previous context when exiting the with statement. If
+ the active thread to a copy of \var{c} on entry to the with-statement
+ and restore the previous context when exiting the with-statement. If
no context is specified, a copy of the current context is used.
+ \versionadded{2.5}
- For example the following code increases the current decimal precision
+ For example, the following code increases the current decimal precision
by 42 places, performs a calculation, and then automatically restores
the previous context:
\begin{verbatim}
from __future__ import with_statement
import decimal
- with decimal.localcontext() as ctx:
+ with localcontext() as ctx:
ctx.prec = 42 # Perform a high precision calculation
s = calculate_something()
s = +s # Round the final result back to the default precision
\end{verbatim}
-
- The context that is held by the context manager and made active in the
- body of the \keyword{with} statement is a \emph{copy} of the context
- you provide to this function, so modifying its attributes doesn't
- affect anything except that temporary copy.
\end{funcdesc}
New contexts can also be created using the \class{Context} constructor