have one or more superclasses this is where multiple inheritance comes in handyby adding listinstance to the list of superclasses in class header ( mixing it in)you get its __str__ "for freewhile still inheriting from the existing superclass(esthe file testmixin py demonstrates with first-cut testing scriptfile testmixin py from listinstance import listinstance get lister tool class class superdef __init__(self)self data 'spamdef ham(self)pass class sub(superlistinstance)def __init__(self)super __init__(selfself data 'eggsself data def spam(self)pass if __name__ ='__main__' sub(print(xsuperclass __init__ create instance attrs mix in ham and __str__ listers have access to self more instance attrs define another method here run mixed-in __str__ heresub inherits names from both super and listinstanceit' composite of its own names and names in both its superclasses when you make sub instance and print ityou automatically get the custom representation mixed in from listinstance (in this casethis script' output is the same under both python and xexcept for object addresseswhich can naturally vary per process) :\codepython testmixin py <instance of subaddress data =spam data =eggs data = this testmixin testing script worksbut it hardcodes the tested class' name in the codeand makes it difficult to experiment with alternatives--as we will in moment to be more flexiblewe can borrow page from ' module reloadersand pass in the object to be testedas in the following improved test scripttestmixin--the one actually used by all the lister class modulesself-test code in this context the object passed in to the tester is mix-in class instead of functionbut the principle is similareverything qualifies as passable "first classobject in python#!python file testmixin py ( ""generic lister mixin testersimilar to transitive reloader in but passes class object to tester (not function)multiple inheritance"mix-inclasses