From: Raymond Hettinger Date: Fri, 11 May 2012 19:50:11 +0000 (-0700) Subject: Additional example of using decimal.localcontext(). X-Git-Tag: v2.7.4rc1~834 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=56f5c38320f25f17b777a4202f6189ec27557783;p=thirdparty%2FPython%2Fcpython.git Additional example of using decimal.localcontext(). --- diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index f9e70de6a966..a4e177ee0b57 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: