polymorphism is actually one of the coolest things about object-oriented programmingand it makes some programming designs obvious that weren' possible in earlier paradigms howeverpython makes polymorphism less cool because of duck typing duck typing in python allows us to use any object that provides the required behavior without forcing it to be subclass the dynamic nature of python makes this trivial the following example does not extend audiofilebut it can be interacted with in python using the exact same interfaceclass flacfiledef __init__(selffilename)if not filename endswith(flac")raise exception("invalid file format"self filename filename def play(self)print("playing {as flacformat(self filename)our media player can play this object just as easily as one that extends audiofile polymorphism is one of the most important reasons to use inheritance in many object-oriented contexts because any objects that supply the correct interface can be used interchangeably in pythonit reduces the need for polymorphic common superclasses inheritance can still be useful for sharing code butif all that is being shared is the public interfaceduck typing is all that is required this reduced need for inheritance also reduces the need for multiple inheritanceoftenwhen multiple inheritance appears to be valid solutionwe can just use duck typing to mimic one of the multiple superclasses of coursejust because an object satisfies particular interface (by providing required methods or attributesdoes not mean it will simply work in all situations it has to fulfill that interface in way that makes sense in the overall system just because an object provides play(method does not mean it will automatically work with media player for exampleour chess ai object from object-oriented designmay have play(method that moves chess piece even though it satisfies the interfacethis class would likely break in spectacular ways if we tried to plug it into media playeranother useful feature of duck typing is that the duck-typed object only needs to provide those methods and attributes that are actually being accessed for exampleif we needed to create fake file object to read data fromwe can create new object that has read(methodwe don' have to override the write method if the code that is going to interact with the object will only be reading from the file more succinctlyduck typing doesn' need to provide the entire interface of an object that is availableit only needs to fulfill the interface that is actually accessed