diff options
author | Raymond Hettinger <python@rcn.com> | 2012-05-11 19:50:11 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2012-05-11 19:50:11 (GMT) |
commit | 56f5c38320f25f17b777a4202f6189ec27557783 (patch) | |
tree | efe9e9ff762732b978ec5015d515a1038ebfb376 | |
parent | acdc56d0d0ccea89d219d126c3ca1b9a28456bd5 (diff) | |
download | cpython-56f5c38320f25f17b777a4202f6189ec27557783.zip cpython-56f5c38320f25f17b777a4202f6189ec27557783.tar.gz cpython-56f5c38320f25f17b777a4202f6189ec27557783.tar.bz2 |
Additional example of using decimal.localcontext().
-rw-r--r-- | Doc/library/decimal.rst | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index f9e70de..a4e177e 100644 --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -944,6 +944,10 @@ the :func:`localcontext` function to temporarily change the active context. s = calculate_something() s = +s # Round the final result back to the default precision + with localcontext(BasicContext): # temporarily use the BasicContext + print Decimal(1) / Decimal(7) + print Decimal(355) / Decimal(113) + New contexts can also be created using the :class:`Context` constructor described below. In addition, the module provides three pre-made contexts: |