single display in all cases--printsnested appearancesand interactive echoes this still allows clients to provide an alternative display with __str__but for limited contexts onlysince this is self-contained examplethis is moot point here the __init__ constructor method we've already coded isstrictly speakingoperator overloading too--it is run automatically at construction time to initialize newly created instance constructors are so commonthoughthat they almost seem like special case more focused methods like __repr__ allow us to tap into specific operations and provide specialized behavior when our objects are used in those contexts let' put this into code the following extends our class to give custom display that lists attributes when our class' instances are displayed as wholeinstead of relying on the less useful default displayadd __repr__ overload method for printing objects class persondef __init__(selfnamejob=nonepay= )self name name self job job self pay pay def lastname(self)return self name split()[- def giveraise(selfpercent)self pay int(self pay ( percent)def __repr__(self)return '[person% % ](self nameself payadded method string to print if __name__ ='__main__'bob person('bob smith'sue person('sue jones'job='dev'pay= print(bobprint(sueprint(bob lastname()sue lastname()sue giveraise print(suenotice that we're doing string formatting to build the display string in __repr__ hereat the bottomclasses use built-in type objects and operations like these to get their work done againeverything you've already learned about both built-in types and functions applies to class-based code classes largely just add an additional layer of structure that packages functions and data together and supports extensions we've also changed our self-test code to print objects directlyinstead of printing individual attributes when runthe output is more coherent and meaningful nowthe "]lines are returned by our new __repr__run automatically by print operations[personbob smith [personsue jones smith jones [personsue jones step operator overloading