On this page
decimal.getcontext
Prev: decimal.FloatOperation | Up: decimal | Next: decimal.IEEEContext
Rel: decimal.Clamped, decimal.Context, decimal.ConversionSyntax, decimal.Decimal
Ref: docs.python.org — decimal.getcontext
Tags: #public #python3 #stdlib #decimal
Import
import decimal
from decimal import getcontext
Signature & Overview
decimal.getcontext()
Get the current default context.
Usage
from decimal import getcontext
ctx = getcontext()
assert ctx.prec >= 1
Gotchas
- Context is thread/async-task local: Prefer
with localcontext() as ctx:over mutatinggetcontext()directly so changes don't leak.
REPL Inspect
from decimal import getcontext
help(getcontext)
Linked from
Related notes
- tuts/python3/stdlib_module/decimal/FloatOperation Linked here; links to this page; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/IEEEContext Linked here; links to this page; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/Clamped Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/Context Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/ConversionSyntax Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/Decimal Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/decimal/DecimalException shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/DecimalTuple shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/DivisionByZero shared tags: #decimal, #stdlib