def findbases(kls, topclass): retval = list() for base in kls.__bases__: if issubclass(base, topclass): retval.extend(findbases(base, topclass)) retval.append(base) return retval class Animal: def __init__(self, name, age): self.name = name self.age = age def print_property(self): print('the name is {} , the age is {}'.format(self.name, self.age)) class dog(Animal): pass kit = dog('kit dog', 2) kit.print_property() kit.name findbases(dog, object)