On this page
math.isfinite
Prev: math.isclose | Up: math | Next: math.isinf
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.isfinite
Tags: #public #python3 #stdlib #math
Import
import math
from math import isfinite
Signature & Overview
math.isfinite(x, /)
Return True if x is neither an infinity nor a NaN, and False otherwise.
Usage
import math
assert math.isfinite(3.14) is True
assert math.isfinite(float("inf")) is False
assert math.isfinite(float("nan")) is False
Gotchas
- Best single guard against both
infandnan: Cleaner than writingnot math.isinf(x) and not math.isnan(x).
REPL Inspect
from math import isfinite
help(isfinite)
Linked from
Related notes
- tuts/python3/stdlib_module/math/isclose Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/isinf Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib