self data *other in-place changenamed thirdclass('abc' display(current value "abcprint( [thirdclassabc__init__ called inherited method called 'xyzb display(current value "abcxyzprint( [thirdclassabcxyz__add__makes new instance has all thirdclass methods mul( print( [thirdclassabcabcabcmulchanges instance in place __str__returns display string __str__returns display string thirdclass "is asecondclassso its instances inherit the customized display method from secondclass of the preceding section this timethoughthirdclass creation calls pass an argument ( "abc"this argument is passed to the value argument in the __init__ constructor and assigned to self data there the net effect is that third class arranges to set the data attribute automatically at construction timeinstead of requiring setdata calls after the fact furtherthirdclass objects can now show up in expressions and print calls for +python passes the instance object on the left to the self argument in __add__ and the value on the right to otheras illustrated in figure - whatever __add__ returns becomes the result of the expression (more on its result in momentfor printpython passes the object being printed to self in __str__whatever string this method returns is taken to be the print string for the object with __str__ (or its more broadly relevant twin __repr__which we'll meet and use in the next we can use normal print to display objects of this classinstead of calling the special display method figure - in operator overloadingexpression operators and other built-in operations performed on class instances are mapped back to specially named methods in the class these special methods are optional and may be inherited as usual herea expression triggers the __add__ method classes can intercept python operators