adapter pattern it implements required_function methodwhich returns the result of calling the provided_function_ (method of its wrapped whatihave object all other calls on the class are passed to its what_i_have instance via the ___getattr__(method you still only need to implement the interface you are adapting objectadapter does not need to inherit the rest of the whatihave interfaceinsteadit supplies __getattr__(to provide the same interface as the whatihave classapart from the methods it implements itself the __getattr__(methodmuch like the __init__(methodis special method in python often called magic methodsthis class of methods is denoted by leading and trailing double underscoressometimes referred to as double under or dunder when the python interpreter does an attribute lookup on the object but can' find itthe __getattr__(method is calledand the attribute lookup is passed to the self what_i_ have object since python uses concept called duck typingwe can simplify our implementation some more duck typing duck typing says that if an animal walks like duck and quacks like duckit is duck put in terms we can understandin python we only care about whether an object offers the interface elements we need if it doeswe can use it like an instance of the interface without the need to declare common parent interfacesuperclass just lost its usefulness and can be removed nowconsider the objectadapter as it makes full use of duck typing to get rid of the interfacesuperclass inheritance from third_party import whatihave class objectadapter(object)def __init__(selfwhat_i_have)self what_i_have what_i_have def required_function(self)return self what_i_have provided_function_ (def __getattr__(selfattr)everything else is handeled by the wrapped object return getattr(self what_i_haveattr