from numbers import Number
from decimal import Decimal
from fractions import Fraction
for n in [2, 2.0, Decimal('2.0'), complex(2, 0), Fraction(2, 1), '2']:
    pass
How can I check if my python object is a number?