#!/usr/bin/python3 # -*- coding: utf-8 -*- thing = "5" # Just get type # type(object) print(type(thing)) # Check type and subtypes if isinstance(thing, str): print("object is instance of str") # To check if the type of o is exactly str (exclude subclasses):] if type(thing) is str: print("object is str") # The following also works, and can be useful in some cases: if issubclass(type(thing), str): print("object is sub-class of str")