Try using isinstance.