How do I check if an object is of a given type, or if it inherits from a given type?
How do I check if the object o is of type str?
isinstance(o, str) will return True if o is an str or is of a type that inherits from str.
type(o) is str will return True if and only if o is a str. It will return False if o is of a type that inherits from str.
What's the canonical way to check for type in Python?