numbers module¶
Metaclass for defining Abstract Base Classes (ABCs). 

Complex defines the operations that work on the builtin complex type. 

Integral adds a conversion to int and the bitstring operations. 

All numbers inherit from this class. 

.numerator and .denominator should be in lowest terms. 

To Complex, Real adds the operations that work on real numbers. 


A decorator indicating abstract methods. 
Abstract Base Classes (ABCs) for numbers, according to PEP 3141.
TODO: Fill out more detailed documentation on the operators.

class
Number
¶ Bases:
object
All numbers inherit from this class.
If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number).

class
Complex
¶ Bases:
numbers.Number
Complex defines the operations that work on the builtin complex type.
In short, those are: a conversion to complex, .real, .imag, +, , *, /, abs(), .conjugate, ==, and !=.
If it is given heterogeneous arguments, and doesn’t have special knowledge about them, it should fall back to the builtin complex type as described below.

conjugate
()¶ (x+y*i).conjugate() returns (xy*i).

imag
¶ Retrieve the imaginary component of this number.
This should subclass Real.

real
¶ Retrieve the real component of this number.
This should subclass Real.


class
Real
¶ Bases:
numbers.Complex
To Complex, Real adds the operations that work on real numbers.
In short, those are: a conversion to float, trunc(), divmod, %, <, <=, >, and >=.
Real also provides defaults for the derived operations.

conjugate
()¶ Conjugate is a noop for Reals.

imag
¶ Real numbers have no imaginary component.

real
¶ Real numbers are their real component.


class
Rational
¶ Bases:
numbers.Real
.numerator and .denominator should be in lowest terms.

denominator
¶

numerator
¶


class
Integral
¶ Bases:
numbers.Rational
Integral adds a conversion to int and the bitstring operations.

denominator
¶ Integers have a denominator of 1.

numerator
¶ Integers are their own numerators.
