![]() | Use isinstance for testing class type:
if isinstance(i2, MySub): # treat i2 as a MySub instance |
![]() | Can test if a class is a subclass of another:
if issubclass(MySub, MyBase): ... |
![]() | Can test if two objects are of the same class:
if inst1.__class__ is inst2.__class__(is checks object identity, == checks for equal contents) |
![]() | a.__class__ refers the class object of instance a |