the singleton pattern def error(selflevelmsg)self _write_log("error"msgdef warn(selflevelmsg)self _write_log("warn"msgdef info(selflevelmsg)self _write_log("info"msgdef debug(selflevelmsg)self _write_log("debug"msgthere is quite lot happening hereso just look at the code for minute before show you how this new logger is implemented in another project the first big departure from our previous logger is the addition of the class keywordwhich acts like the def keyword in that it tells python that we are now going to define new class thenwe have the class namewhich we will use when we want to create new object of this class (called an instanceas you might have guessedone of the main benefits of object-oriented programming (oopis that once you define classyou are able to reuse the class to create other classes this process is called inheritancesince the child class inherits the traits (data and function blueprintfrom the parent class (the class that is used to create the childin pythonevery class ultimately inherits from the object class in the case of our loggerwe have no other class we are using as baseso here we just say that logger only has object as its parent nextwe have bit of text wrapped in ""charactersdenoting that the text contained is doc string certain integrated development environments (idesand other programs know to look for these strings and use them to help guide programmers who want to use this class classes are not the only structures that can make use of doc stringand you will also see that functions can have their own doc stringslike the __init__ function the __init__ is called whenever new logger object is instantiated in this caseit takes the name of file as an argument and associates that with the instance that is being created when we want to reference this file namewe have to tell the method in the object to look for the file_name in its own list of attributes the self keyword is used to let the code know we are referring to an attribute or method associated with an object from which the call is madeandas suchit should not be looking somewhere else for these elements