Oct-01-2017, 11:12 AM
It's better to use isinstance() than type() for this.
>>> t = (100,200,150) >>> if isinstance(t, tuple) and len(t) == 3: ... print("It's most likely a rgb color tuple") ... else: ... print('Not a color tuple') ... It's most likely a rgb color tuple >>> t = [100,200,155] >>> if isinstance(t, tuple) and len(t) == 3: ... print("It's most likely a rgb color tuple") ... else: ... print('Not a color tuple') ... Not a color tuple >>> t = (100,200) >>> if isinstance(t, tuple) and len(t) == 3: ... print("It's most likely a rgb color tuple") ... else: ... print('Not a color tuple') ... Not a color tuple