__str__ is to print(the value def __str__(self)return(repr(self value)tryraise(myerror( * )value of exception is stored in error except myerror as errorprint(' new exception occured',error valueouput(' new exception occured' summary filespython supports file handling and allows users to handle files for exampleto read and write filesalong with many other file handling optionsto operate on files the concept of file handling has justified by various other languagesbut the implementation is either difficult python delights file differently as text or binary and this is significant each line of code includes sequence of characters and they form text file each line of file is ended with special character like comma {,it ends the current line and expresses the interpreter new one has started in python file is contiguous set of bytes used to store data this data is organized in precise format and can be anything as simple as text file in the endthese byte files are then translated into binary and for simple for processing in pythona file operation takes place in the order like open file then read or write and finally close the file exceptionspython provides two important features to handle any unexpected error in python programs and to add debugging capabilities in them in pythonall exceptions must be occurrences of class that arises from baseexception in try statement with an except clause that references particular classthat clause further handles any exception classes derived from that class two exception classes that are not connected via sub classing are never equaleven if they have the same name user code can advance built-in exceptions this can be used to test an exception handler and also to report an error condition