pass xy toptest()subtest(print(xprint(ymake two instances show all instance attrs show lowest class name notice the docstrings here--because this is general-purpose toolwe want to add some functional documentation for potential users to read as we saw in docstrings can be placed at the top of simple functions and modulesand also at the start of classes and any of their methodsthe help function and the pydoc tool extract and display these automatically we'll revisit docstrings for classes in when run directlythis module' self-test makes two instances and prints themthe __repr__ defined here shows the instance' classand all its attributes names and valuesin sorted attribute name order this output is the same in python and because each object' display is single constructed stringc:\codeclasstools py [toptestattr = attr = [subtestattr = attr = another design note herebecause this class uses __repr__ instead of __str__ its displays are used in all contextsbut its clients also won' have the option of providing an alternative low-level display--they can still add __str__but this applies to print and str only in more general toolusing __str__ instead limits display' scopebut leaves clients the option of adding __repr__ for secondary display at interactive prompts and nested appearances we'll follow this alternative policy when we code expanded versions of this class in for this demowe'll stick with the allinclusive __repr__ instance versus class attributes if you study the classtools module' self-test code long enoughyou'll notice that its class displays only instance attributesattached to the self object at the bottom of the inheritance treethat' what self' __dict__ contains as an intended consequencewe don' see attributes inherited by the instance from classes above it in the tree ( count in this file' self-test code-- class attribute used as an instance counterinherited class attributes are attached to the class onlynot copied down to instances if you ever do wish to include inherited attributes tooyou can climb the __class__ link to the instance' classuse the __dict__ there to fetch class attributesand then iterate through the class' __bases__ attribute to climb to even higher superclassesrepeating as necessary if you're fan of simple coderunning built-in dir call on the instance instead of using __dict__ and climbing would have much the same effectsince dir results include inherited names in the sorted results list in python from person import person bob person('bob smith' xkeys is listdir shows less step using introspection tools