tutorial introduction method always refers to the object itself by conventionself is the name used for this argument all operations involving the attributes of an object must explicitly refer to the self variable methods with leading and trailing double underscores are special methods for example_ _init_ is used to initialize an object after it' created to use classwrite code such as the followings stack( push("dave" push( push([ , , ] pop( pop(del create stack push some things onto it gets [ , , gets destroy in this examplean entirely new object was created to implement the stack howevera stack is almost identical to the built-in list object thereforean alternative approach would be to inherit from list and add an extra methodclass stack(list)add push(method for stack interface notelists already provide pop(method def push(self,object)self append(objectnormallyall of the methods defined within class apply only to instances of that class (that isthe objects that are createdhoweverdifferent kinds of methods can be defined such as static methods familiar to +and java programmers for exampleclass eventhandler(object)@staticmethod def dispatcherthread()while ( )wait for requests eventhandler dispatcherthread(call method like function in this case@staticmethod declares the method that follows to be static method @staticmethod is an example of using an decoratora topic that is discussed further in exceptions if an error occurs in your programan exception is raised and traceback message such as the following appearstraceback (most recent call last)file "foo py"line in ioerror[errno no such file or directory'file txtthe traceback message indicates the type of error that occurredalong with its location normallyerrors cause program to terminate howeveryou can catch and handle exceptions using try and except statementslike thistryf open("file txt"," "except ioerror as eprint lib fl ff