classes and object-oriented programming oopsla' subtle aspect of this algorithm is that certain class hierarchies will be rejected by python with typeerror here' an exampleclass (object)pass class ( )pass class ( , )pass typeerror can' create consistent method resolution order_ in this casethe method resolution algorithm rejects class because it can' determine an ordering of the base classes that makes sense for examplethe class appears before class in the inheritance listso it must be checked first howeverclass is more specialized because it inherits from thereforeif is checked firstit would not be possible to resolve specialized methods in in practicethese issues should rarely arise--and if they doit usually indicates more serious design problem with program as general rulemultiple inheritance is something best avoided in most programs howeverit is sometimes used to define what are known as mixin classes mixin class typically defines set of methods that are meant to be "mixed into other classes in order to add extra functionality (almost like macrotypicallythe methods in mixin will assume that other methods are present and will build upon them the depositcharge and withdrawcharge classes in the earlier example illustrate this these classes add new methods such as deposit_fee(to classes that include them as one of the base classes howeveryou would never instantiate depositcharge by itself in factif you didit wouldn' create an instance that could be used for anything useful (that isthe one defined method wouldn' even execute correctlyjust as final noteif you wanted to fix the problematic references to fee in this examplethe implementation of deposit_fee(and withdraw_fee(should be changed to refer to the attribute directly using the class name instead of self (for exampledepositchange feepolymorphism dynamic binding and duck typing dynamic binding (also sometimes referred to as polymorphism when used in the context of inheritanceis the capability to use an instance without regard for its type it is handled entirely through the attribute lookup process described for inheritance in the preceding section whenever an attribute is accessed as obj attrattr is located by searching within the instance itselfthe instance' class definitionand then base classesin that order the first match found is returned critical aspect of this binding process is that it is independent of what kind of object obj is thusif you make lookup such as obj nameit will work on any obj that happens to have name attribute this behavior is sometimes referred to as duck typing in reference to the adage "if it looks likequacks likeand walks like duckthen it' duck python programmers often write programs that rely on this behavior for exampleif you want to make customized version of an existing objectyou can either inherit from it or you can simply create completely new object that looks and acts like it but is otherwise unrelated this latter approach is often used to maintain loose coupling of program components for examplecode may be written to work with any kind of object whatsoever as long as it has certain set of methods one of the most common examples is with various "file-likeobjects defined in the standard library although these objects work like filesthey don' inherit from the built-in file object lib fl ff