0

I'm explicitly type checking an object and am stumped.

The following returns True:

>>>type(data_id['CharacteristicLabel']) is bool
True

I need to check if that object data_id['CharacteristicLabel'] is either int or float or bool, so I thought of doing this, which returns False:

>>>type(data_id['CharacteristicLabel']) is (int or float or bool)
False

What is the proper way to do this?

cs95
  • 379,657
  • 97
  • 704
  • 746
simplycoding
  • 2,770
  • 9
  • 46
  • 91

1 Answers1

0

use isinstance

isinstance(somenumber, (int, float))

Sedy Vlk
  • 565
  • 4
  • 12