classes and object-oriented programming returning to our examplethe code print 'is student is' isstudent(print 'is student is' isstudent(print 'is student is' isstudent(prints buzz aldrin is student is true billy beaver is student is true billy bob beaver is student is false notice that isinstance( studentis quite different from type( =student the object to which is bound is of type ugnot studentbut since ug is subclass of studentthe object to which is bound is considered to be an instance of class student (as well as an instance of mitperson and personsince there are only two kinds of studentswe could have implemented isstudent asdef isstudent(self)return type(self=grad or type(self=ug howeverif new type of student were introduced at some later point it would be necessary to go back and edit the code implementing isstudent by introducing the intermediate class student and using isinstance we avoid this problem for exampleif we were to add class transferstudent(student)def __init__(selfnamefromschool)mitperson __init__(selfnameself fromschool fromschool def getoldschool(self)return self fromschool no change needs to be made to isstudent it is not unusual during the creation and later maintenance of program to go back and add new classes or new attributes to old classes good programmers design their programs so as to minimize the amount of code that might need to be changed when that is done the substitution principle when subclassing is used to define type hierarchythe subclasses should be thought of as extending the behavior of their superclasses we do this by adding new attributes or overriding attributes inherited from superclass for exampletransferstudent extends student by introducing former school sometimesthe subclass overrides methods from the superclassbut this must be done with care in particularimportant behaviors of the supertype must be supported by each of its subtypes if client code works correctly using an instance of the supertypeit should also work correctly when an instance of the subtype is substituted for the instance of the supertype for exampleit should