[Python-checkins] cpython (2.7): Additional example of using decimal.localcontext().

raymond.hettinger python-checkins at python.org
Fri May 11 21:50:23 CEST 2012


http://hg.python.org/cpython/rev/a8af63c83f53
changeset: 76878:a8af63c83f53
branch: 2.7
parent: 76869:e12efebc3ba6
user: Raymond Hettinger <python at rcn.com>
date: Fri May 11 12:50:11 2012 -0700
summary:
 Additional example of using decimal.localcontext().
files:
 Doc/library/decimal.rst | 4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -944,6 +944,10 @@
 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:
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /