better coded as simple function than class with constructorbut the class here serves to illustrate its callable natureclass negatedef __init__(selfval)self val -val def __repr__(self)return str(self valclasses are callables too but called for objectnot work instance print format actions [squaresobjectpobject methodnegatefor act in actionsprint(act( ) - [act( for act in actions[ - table {act( )act for act in actionsfor (keyvaluein table items()print('{ : ={ }format(keyvalue)call class too runs __repr__ not __str__ / dict comprehension +/ str format = =- = =as you can seebound methodsand python' callable objects model in generalare some of the many ways that python' design makes for an incredibly flexible language you should now understand the method object model for other examples of bound methods at worksee the upcoming sidebar "why you will carebound method callbackson page as well as the prior discussion of callback handlers in the section on the method __call__ why you will carebound method callbacks because bound methods automatically pair an instance with class' method functionyou can use them anywhere simple function is expected one of the most common places you'll see this idea put to work is in code that registers methods as event callback handlers in the tkinter gui interface (named tkinter in python xwe've met before as reviewhere' the simple casedef handler()use globals or closure scopes for state widget button(text='spam'command=handlerto register handler for button click eventswe usually pass callable object that takes no arguments to the command keyword argument function names (and lambdaswork methods are objectsbound or unbound