advanced programming techniques the filestack class has all the undo methodsand also the loadsave class' save(and load(methods we have not reimplemented save(since it works finebut for load(we must clear the undo stack after loading this is necessary because we might do savethen do various changesand then load the load wipes out what went beforeso any undos no longer make sense the original undo class did not have clear(methodso we had to add onedef clear(self)self __undos [in class undo in the stack load(method we have used super(to call loadsave load(because there is no undo load(method to cause ambiguity if both base classes had had load(methodthe one that would get called would depend on python' method resolution order we prefer to use super(only when there is no ambiguityand to use the appropriate base name otherwiseso we never rely on the method resolution order for the self clear(callagain there is no ambiguity since only the undo class has clear(methodand we don' need to use super(since (unlike load()filestack does not have clear(method what would happen iflater ona clear(method was added to the filestack classit would break the load(method one solution would be to call super(clear(inside load(instead of plain self clear(this would result in the first super-class' clear(method that was found being used to protect against such problems we could make it policy to use hard-coded base classes when using multiple inheritance (in this examplecalling undo clear(self)or we could avoid multiple inheritance altogether and use aggregationfor exampleinheriting the undo class and creating loadsave class designed for aggregation what multiple inheritance has given us here is mixture of two rather different classeswithout the need to implement any of the undo or the loading and saving ourselvesrelying instead on the functionality provided by the base classes this can be very convenient and works especially well when the inherited classes have no overlapping apis metaclasses | metaclass is to class what class is to an instancethat isa metaclass is used to create classesjust as classes are used to create instances and just as we can ask whether an instance belongs to class by using isinstance()we can ask whether class object (such as dictintor sortedlistinherits another class using issubclass(the simplest use of metaclasses is to make custom classes fit into python' standard abc hierarchy for exampleto make sortedlist collections