in this examplethe __call__ may seem bit gratuitous at first glance simple method can provide similar utilityclass proddef __init__(selfvalue)self value value def comp(selfother)return self value other prod( comp( comp( however__call__ can become more useful when interfacing with apis ( librariesthat expect functions--it allows us to code objects that conform to an expected function call interfacebut also retain state informationand other class assets such as inheritance in factit may be the third most commonly used operator overloading methodbehind the __init__ constructor and the __str__ and __repr__ display-format alternatives function interfaces and callback-based code as an examplethe tkinter gui toolkit (named tkinter in python xallows you to register functions as event handlers ( callbacks)--when events occurtkinter calls the registered objects if you want an event handler to retain state between eventsyou can register either class' bound methodor an instance that conforms to the expected interface with __call__ in the prior section' codefor exampleboth comp from the second example and from the first can pass as function-like objects this way ' closure functions with state in enclosing scopes can achieve similar effectsbut don' provide as much support for multiple operations or customization 'll have more to say about bound methods in the next but for nowhere' hypothetical example of __call__ applied to the gui domain the following class defines an object that supports function-call interfacebut also has state information that remembers the color button should change to when it is later pressedclass callbackdef __init__(selfcolor)self color color def __call__(self)print('turn'self colorfunction state information support calls with no arguments call expressions__call__