Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f1f42d85
Commit
f1f42d85
authored
Sep 03, 2006
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix final documentation nits before backporting decimal module fixes to 2.5
parent
c1120b4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
Doc/lib/libdecimal.tex
Doc/lib/libdecimal.tex
+3
-3
Doc/whatsnew/whatsnew25.tex
Doc/whatsnew/whatsnew25.tex
+4
-3
No files found.
Doc/lib/libdecimal.tex
View file @
f1f42d85
...
...
@@ -453,12 +453,12 @@ active context.
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
by
42 places, performs a calculation, and then automatically restores
For example, the following code
set
the current decimal precision
to
42 places, performs a calculation, and then automatically restores
the previous context:
\begin{verbatim}
from
__
future
__
import with
_
statement
import decimal
from decimal import localcontext
with localcontext() as ctx:
ctx.prec = 42 # Perform a high precision calculation
...
...
Doc/whatsnew/whatsnew25.tex
View file @
f1f42d85
...
...
@@ -683,9 +683,10 @@ with lock:
The lock is acquired before the block is executed and always released once
the block is complete.
The
\module
{
decimal
}
module's contexts, which encapsulate the desired
precision and rounding characteristics for computations, provide a
\function
{
localcontext()
}
function for getting a context manager:
The new
\function
{
localcontext()
}
function in the
\module
{
decimal
}
module
makes it easy to save and restore the current decimal context, which
encapsulates the desired precision and rounding characteristics for
computations:
\begin{verbatim}
from decimal import Decimal, Context, localcontext
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment