['pay''job''name'instance attrs only dir(bobplus inherited attrs in classes ['__doc__''__init__''__module__''__repr__''giveraise''job''lastname''name''pay'if you're using python xyour output will varyand may be more than you bargained forhere' the result for the last two statements (keys list order can vary per run)list(bob __dict__ keys()['name''job''pay' keys is viewnot list dir(bob includes class type methods ['__class__''__delattr__''__dict__''__dir__''__doc__''__eq__''__format__''__ge__''__getattribute__''__gt__''__hash__''__init__'more omitted attrs '__setattr__''__sizeof__''__str__''__subclasshook__''__weakref__''giveraise''job''lastname''name''pay'the code and output here varies between python and xbecause ' dict keys is not listand ' dir returns extra class-type implementation attributes technicallydir returns more in because classes are all "new styleand inherit large set of operator overloading names from the class type in factas usual you'll probably want to filter out most of the __x__ names in the dir resultsince they are internal implementation details and not something you' normally want to displaylen(dir(bob) list(name for name in dir(bobif not name startswith('__')['giveraise''job''lastname''name''pay'in the interest of spacewe'll leave optional display of inherited class attributes with either tree climbs or dir as suggested experiments for now for more hints on this frontthoughwatch for the classtree py inheritance tree climber we will write in and the lister py attribute listers and climbers we'll code in name considerations in tool classes one last subtlety herebecause our attrdisplay class in the classtools module is general tool designed to be mixed into other arbitrary classeswe have to be aware of the potential for unintended name collisions with client classes as isi've assumed that client subclasses may want to use both its __repr__ and gatherattrsbut the latter of these may be more than subclass expects--if subclass innocently defines gather attrs name of its ownit will likely break our classbecause the lower version in the subclass will be used instead of ours to see this for yourselfadd gatherattrs to toptest in the file' self-test codeunless the new method is identicalor intentionally customizes the originalour tool class will more realistic example