So if I add a rect to a variable like so
box = pygame.Rect(x, y, w, h)
How do I check if the variable rect holds a pygame.Rect
? Ideally it would return something similar to this
int = 9
#int is not a rect
#box is a rect
Use isinstance(object, classinfo)
:
Return
True
if the object argument is an instance of the classinfo argument [...]
if isinstance(box, pygame.Rect):
print('is a rect')
else:
print('is not a rect')