On this page
  1. decimal.setcontext
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

decimal.setcontext

Prev: decimal.Rounded | Up: decimal | Next: decimal.Subnormal
Rel: decimal.Clamped, decimal.Context, decimal.ConversionSyntax, decimal.Decimal
Ref: docs.python.org — decimal.setcontext
Tags: #public #python3 #stdlib #decimal


Import

import decimal
from decimal import setcontext

Signature & Overview

decimal.setcontext(context, /)

Set a new default context.

Usage

from decimal import Context, getcontext, setcontext

old = getcontext()
setcontext(Context(prec=10))
try:
    assert getcontext().prec == 10
finally:
    setcontext(old)

Gotchas

REPL Inspect

from decimal import setcontext
help(setcontext)

Linked from

Related notes