From 56f5c38320f25f17b777a4202f6189ec27557783 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 11 May 2012 12:50:11 -0700 Subject: [PATCH] Additional example of using decimal.localcontext(). --- Doc/library/decimal.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index f9e70de6a96..a4e177ee0b5 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: