import numbersimport decimalisinstance(1, numbers.Number) # Trueisinstance(0.1, numbers.Number) # Trueisinstance(decimal.Decimal(1), numbers.Number) # Trueisinstance(True, numbers.Number) # Trueisinstance(float('nan'), numbers.Number) # True
Make sure is number and not boolean
import numbersvalue = 0if isinstance(value, numbers.Number) and not isinstance(value, bool): print(value, 'is number and not a boolean')