and the class that is inherited from is its superclass classes inherit attributes from their superclasses just as instances inherit the attribute names defined in their classesclasses inherit all of the attribute names defined in their superclassespython finds them automatically when they're accessedif they don' exist in the subclasses instances inherit attributes from all accessible classes each instance gets names from the class it' generated fromas well as all of that class' superclasses when looking for namepython checks the instancethen its classthen all superclasses each object attribute reference invokes newindependent search python performs an independent search of the class tree for each attribute fetch expression this includes references to instances and classes made outside class statements ( attr)as well as references to attributes of the self instance argument in class' method functions each self attr expression in method invokes new search for attr in self and above logic changes are made by subclassingnot by changing superclasses by redefining superclass names in subclasses lower in the hierarchy (class tree)subclasses replace and thus customize inherited behavior the net effect--and the main purpose of all this searching--is that classes support factoring and customization of code better than any other language tool we've seen so far on the one handthey allow us to minimize code redundancy (and so reduce maintenance costsby factoring operations into singleshared implementationon the otherthey allow us to program by customizing what already existsrather than changing it in place or starting from scratch strictly speakingpython' inheritance is bit richer than described herewhen we factor in new-style descriptors and metaclasses--advanced topics we'll study later--but we can safely restrict our scope to instances and their classesboth at this point in the book and in most python application code we'll define inheritance formally in second example to illustrate the role of inheritancethis next example builds on the previous one firstwe'll define new classsecondclassthat inherits all of firstclass' names and provides one of its ownclass secondclass(firstclass)inherits setdata def display(self)changes display print('current value "% "self data class coding basics