Data Modeling and Utility Modules
numbers
Defines numeric abstract base classes, from Number through Complex, Real, Rational and Integral. They describe numeric interfaces rather than concrete constructors. Membership depends on subclassing or registration; Decimal, for example, is not registered as Real.
Formal Syntax & Structure
python syntaxpython
import numbersReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from numbers import Integral, Realfrom fractions import Fractionprint(isinstance(4, Integral))print(isinstance(Fraction(1, 3), Real))