__repr__or else this loops when printing bound methods""def __attrnames(self)result 'for attr in dir(self)instance dir(if attr[: ='__and attr[- :='__'skip internals result +'\ % \nattr elseresult +'\ % =% \ (attrgetattr(selfattr)return result def __str__(self)return 'self __class__ __name__id(self)self __attrnames()my class' name my address name=value list if __name__ ='__main__'import testmixin testmixin tester(listinheritednotice that this code skips __x__ namesvaluesmost of these are internal names that we don' generally care about in generic listing like this this version also must use the getattr built-in function to fetch attributes by name string instead of using instance attribute dictionary indexing--getattr employs the inheritance search protocoland some of the names we're listing here are not stored on the instance itself to test the new versionrun its file directly--it passes the class it defines to the testmixin py file' test function to be used as mix-in in subclass this output of this test and lister class varies per releasethoughbecause dir results differ in python xwe get the followingnotice the name mangling at work in the lister' method name ( truncated some of the full value displays to fit on this page) :\codec:\python \python listinherited py <instance of subaddress _listinherited__attrnames=__doc__ __init__ __module__ __str__ data =spam data =eggs data = ham=spam=in python xmore attributes are displayed because all classes are "new styleand inherit names from the implied object superclassmore on this in because so many names are inherited from the default superclassi've omitted many here-there are in total in run this on your own for the full listing designing with classes