On this page
decimal.Inexact
Prev: decimal.IEEEContext | Up: decimal | Next: decimal.InvalidContext
Rel: decimal.Clamped, decimal.Context, decimal.ConversionSyntax, decimal.Decimal
Ref: docs.python.org โ decimal.Inexact
Tags: #public #python3 #stdlib #decimal
Import
import decimal
from decimal import Inexact
Signature & Overview
decimal.Inexact(...)
decimal.Inexact class.
Methods & Attributes
Inexact.add_note(self, note, /)โ Add a note to the exceptionInexact.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
from decimal import Decimal, Inexact, localcontext
with localcontext() as ctx:
ctx.traps[Inexact] = True
try:
_ = Decimal("1") / Decimal("3")
except Inexact:
assert True
Gotchas
- Untrapped by default: Trap
Inexactonly when you need to guarantee exact non-repeating results.
REPL Inspect
from decimal import Inexact
help(Inexact)
Linked from
Related notes
- tuts/python3/stdlib_module/decimal/IEEEContext Linked here; links to this page; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/InvalidContext 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