1

I am doing a loop and setting a variable but I need to know if it is NoneType.

get_background = wb.colour_map[bgc]
if isinstance(get_background, None):
    #do stuff

Getting `typeerror: isinstance () arg 2 must be a type or tuple of types

if type(get_background) is 'NoneType':
    #do stuff.

This just gets skipped over and my code blows up. How do I check if get_background is of NoneType.

print(type(get_background))
<class 'Nonetype'>
user3525290
  • 1,557
  • 2
  • 20
  • 47
  • 1
    Try just using `isinstance(get_background, type(None))` or even just `get_background is None`, since None is the only value that can be NoneType. – Turksarama Aug 01 '18 at 00:47
  • Sweetness. I thought I tried `get_background is None` but clearly I did not. – user3525290 Aug 01 '18 at 00:51

0 Answers0