for exampleas we've seenpython' default way to print class instance object isn' incredibly usefulclass spamdef __init__(self)self data "foodx spam(print(xno __repr__ or __str__ defaultclass name address (idsame in xbut says "instanceas you saw in both ' case study and ' operator overloading coverageyou can provide __str__ or __repr__ method to implement custom string representation of your own butrather than coding one of these in each and every class you wish to printwhy not code it once in general-purpose tool class and inherit it in all your classesthat' what mix-ins are for defining display method in mix-in superclass once enables us to reuse it anywhere we want to see custom display format--even in classes that may already have another superclass we've already seen tools that do related work' attrdisplay class formatted instance attributes in generic __repr__ methodbut it did not climb class trees and was utilized in single-inheritance mode only ' classtree py module defined functions for climbing and sketching class treesbut it did not display object attributes along the way and was not architected as an inheritable class herewe're going to revisit these examplestechniques and expand upon them to code set of three mix-in classes that serve as generic display tools for listing instance attributesinherited attributesand attributes on all objects in class tree we'll also use our tools in multiple-inheritance mode and deploy coding techniques that make classes better suited to use as generic tools unlike we'll also code this with __str__ instead of __repr__ this is partially style issue and limits their role to print and strbut the displays we'll be developing will be rich enough to be categorized as more user-friendly than as-code this policy also leaves client classes the option of coding an alternative lower-level display for interactive echoes and nested appearances with __repr__ using __repr__ here would still allow an alternative __str__but the nature of the displays we'll be implementing more strongly suggests __str__ role see for review of these distinctions designing with classes