all Python 3cmathfunction
cmath.isinf()
checking
Checks whether at least one part of a complex number, real or imaginary, is infinite.
Syntax
cmath.isinf(z)
One infinite part is enough, even if the other is NaN: isinf(complex(nan, inf)) is True, and isnan of the same number is True as well. So isinf and isnan are not mutually exclusive, and the order of if/elif when handling special values changes the result.
Examples
import cmath
z = complex(float('nan'), float('inf'))
print(cmath.isinf(z), cmath.isnan(z)) # → True True
print(cmath.isinf(cmath.infj)) # → True
See also
Open in the full glossarydocs.python.orgReport an inaccuracy