the toptest instanceclass toptest(attrdisplay)def gatherattrs(self)return 'spamreplaces method in attrdisplaythis isn' necessarily bad--sometimes we want other methods to be available to subclasseseither for direct calls or for customization this way if we really meant to provide __repr__ onlythoughthis is less than ideal to minimize the chances of name collisions like thispython programmers often prefix methods not meant for external use with single underscore_gatherattrs in our case this isn' foolproof (what if another class defines _gatherattrstoo?)but it' usually sufficientand it' common python naming convention for methods internal to class better and less commonly used solution would be to use two underscores at the front of the method name only__gatherattrs for us python automatically expands such names to include the enclosing class' namewhich makes them truly unique when looked up by the inheritance search this is feature usually called pseudoprivate class attributeswhich we'll expand on in and deploy in an expanded version of this class there for nowwe'll make both our methods available our classesfinal form nowto use this generic tool in our classesall we need to do is import it from its modulemix it in by inheritance in our top-level classand get rid of the more specific __repr__ we coded before the new display overload method will be inherited by instances of personas well as managermanager gets __repr__ from personwhich now obtains it from the attrdisplay coded in another module here is the final version of our person py file with these changes appliedfile classtools py (newas listed earlier file person py (final""record and process information about people run this file directly to test its classes ""from classtools import attrdisplay class person(attrdisplay)""create and process person records ""def __init__(selfnamejob=nonepay= )self name name self job job self pay pay use generic display tool mix in repr at this level step using introspection tools