def __init__(selfcolor)self color color def changecolor(self)print('turn'self colorclass with state information normal named method cb callback('blue'cb callback('yellow' button(command=cb changecolorb button(command=cb changecolorbound methodreferencedon' call remembers function self pair in this casewhen this button is later pressed it' as if the gui does thiswhich invokes the instance' changecolor method to process the object' state informationinstead of the instance itselfcb callback('blue'obj cb changecolor obj(registered event handler on event prints 'turn bluenote that lambda is not required herebecause bound method reference by itself already defers call until later this technique is simplerbut perhaps less general than overloading calls with __call__ againwatch for more about bound methods in the next you'll also see another __call__ example in where we will use it to implement something known as function decorator-- callable object often used to add layer of logic on top of an embedded function because __call__ allows us to attach state information to callable objectit' natural implementation technique for function that must remember to call another function when called itself for more __call__ examplessee the state retention preview examples in and the more advanced decorators and metaclasses of and comparisons__lt____gt__and others our next batch of overloading methods supports comparisons as suggested in table - classes can define methods to catch all six comparison operators===and !these methods are generally straightforward to usebut keep the following qualifications in mindunlike the __add__/__radd__ pairings discussed earlierthere are no right-side variants of comparison methods insteadreflective methods are used when only one operand supports comparison ( __lt__ and __gt__ are each other' reflectionthere are no implicit relationships among the comparison operators the truth of =does not imply that !is falsefor exampleso both __eq__ and __ne__ should be defined to ensure that both operators behave correctly in python xa __cmp__ method is used by all comparisons if no more specific comparison methods are definedit returns number that is less thanequal toor comparisons__lt____gt__and others