What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type?
Let\'s say I have an objec
You can check for type of a variable using __name__ of a type.
Ex:
>>> a = [1,2,3,4] >>> b = 1 >>> type(a).__name__ 'list' >>> type(a).__name__ == 'list' True >>> type(b).__name__ == 'list' False >>> type(b).__name__ 'int'