]> granicus.if.org Git - python/commitdiff
Additional example of using decimal.localcontext().
authorRaymond Hettinger <python@rcn.com>
Fri, 11 May 2012 19:50:11 +0000 (12:50 -0700)
committerRaymond Hettinger <python@rcn.com>
Fri, 11 May 2012 19:50:11 +0000 (12:50 -0700)
Doc/library/decimal.rst

index f9e70de6a9662a0472e4454464e8056c7b11796d..a4e177ee0b57d97cbbd583d06420053114f0d73f 100644 (file)
@@ -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: